I'm using a product called vlad which is making non-interactive ssh connections to my Ubuntu server but the problem is that it can't see any of the environment variables.

I've been googling like crazy but can't find a solution. I've tried adding the variables to an .ssh/environment file for the user on my server and also changing the settings in /etc/ssh/sshd_config but no joy.

Can anyone help?




Check you /etc/ssh/ssh_config (on client) and look at SendEnv option. In my case, I have SendEnv LANG LC_*.

There is some interresting informtions in the man ssh_config

  • Thanks for the response Dom, sorry my question wasn't very clear I was really looking for a solution on the server so I don't need to setup something on each client. Feb 4 '10 at 8:52
  • 1
    Unfortunately, the client doesn't send environment variables unless you tell it which ones to send. If you have many clients to setup, you might consider using a tool to deploy your SSH client configuration, such as puppet.
    – raphink
    Feb 4 '10 at 10:56

If you have control of the ssh command call itself, you can try something like this:

ssh user@remoteserver MYVAR1="$MYVAR1" MYVAR2="$MYVAR2" command

I also use "tee" (for visual clarity) and heredoc to send remote bash scripts:

tee << '+++' | ssh user@remoteserver MYVAR1="$MYVAR1" MYVAR2="$MYVAR2" bash
  set -x
  echo "hey, your variable is $MYVAR1"
  echo "and your other variable is $MYVAR2"

Do you have the environmental variables defined in ~/.bashrc on the server? Sometimes somethings read ~/.profile instead. One trick I do is to symlink ~/.profile to ~/.bashrc,


ln -s ~/.bashrc ~/.profile

my guess is your environment variables are in the wrong file. there are two different files which get sourced for login/interactive shells.

take a look at this post:
What is the difference between a 'Login' and an 'Interactive' bash shell

EDIT: ok, now for non-interactive logins:
are you login in with a key? when yes, you can add this to your authorized_keys file:

         Specifies that the string is to be added to the environment when logging in using this key.  Environment variables set this way override other
         default environment values.  Multiple options of this type are permitted.  Environment processing is disabled by default and is controlled via
         the PermitUserEnvironment option.  This option is automatically disabled if UseLogin is enabled.

(from man sshd)

  • I'm interested in non-interactive shells Feb 4 '10 at 12:46
  • sorry, haven't read this. i've edited my answer accordingly.
    – Christian
    Feb 4 '10 at 13:54
  • No that didn't work either. Feb 5 '10 at 1:56

What is the shell of that user on the server? If it's bash, then ~/.bash_profile or ~/.profile containing all the variables (or something like ". /etc/environment") should work. If it's not bash, consider changing :)


@Dom (I can't post comment): for me it's working /etc/ssh/sshd_config

AcceptEnv LANG LC_*

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.