Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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?

Cheers,

Chris

share|improve this question

6 Answers 6

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

share|improve this answer
    
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. –  ChrisInCambo 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. –  ℝaphink 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"
+++
share|improve this answer

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,

e.g.:

ln -s ~/.bashrc ~/.profile
share|improve this answer
    
That didn't work –  ChrisInCambo Feb 4 '10 at 12:45

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:
http://serverfault.com/questions/8882/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:

environment="NAME=value"
         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)

share|improve this answer
    
I'm interested in non-interactive shells –  ChrisInCambo 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. –  ChrisInCambo 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 :)

share|improve this answer

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

AcceptEnv LANG LC_*
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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