I am doing ssh to a Open SUSE linux server from windows cygwin. I am trying to send one of my local environment variable through the ssh command so that I can load some specific .bashrc file right after logging in. Here is what I have tried with.

Windows Machine has this env variable


In linux machine I have

vim /etc/ssh/sshd_config

In /home/user/.bashrc I have written something like


My plan is to have a file like .bashrc.samiron and do source ~/.bashrc.$ME from .bashrc file.

However, I am doing ssh like below and expecting the variable $ME to contain "samiron"

ssh -o SendEnv=IDENTITY user@server.com

But after logging

user@server:~> echo $ME

Its shows nothing. Anyone can suggest me what I am doing wrong here?


These two conditions should be met before it can work as expected:

  1. Your ssh server has to be configured to accept forwarding of variables from local client's environment. As it may be a security risk to allow such behavior it is usually disabled by default. You can enable it by specifying "AcceptEnv" directive in your ssh server configuration. So put something like this to /etc/ssh/sshd_config file and reload the ssh server service (variable names can contain wildcards, you can specify multiple variables separated by whitespaces, details in man sshd_config)


  2. This feature works for ssh protocol of version 2 only. This is fulfilled almost in all modern Linux distribution by default if it wasn't changed ("Protocol" directive).


Oh I was missing the part of restarting the sshd server.

sudo /etc/init.d/sshd restart

solved my problem

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.