Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In ssh_config, one can choose to export some environment variables to the host using SendEnv.

Is there also a way to force a given value for this variable, per host? For example, would it be possible to export variable $FOO with value bar only when connecting to host

share|improve this question
up vote 10 down vote accepted

You can't give a specific value for an environment variable in ssh_config, but you can certainly send the existing environment variable only to specific hosts.

    SendEnv FOO

To complete the chain:

FOO=bar ssh

Finally, the remote server must have the environment variable listed in AcceptEnv in its sshd_config.

AcceptEnv FOO
share|improve this answer
Thanks. That's precisely what I'd like to avoid. – ℝaphink Feb 27 '13 at 7:30
WHAT is precisely what you'd like to avoid? – Michael Hampton Feb 27 '13 at 7:32
Having to write an alias in order to send a variable with a given value. – ℝaphink Feb 27 '13 at 7:35
Sorry, not much else you can do... unless you can get the computer to read your mind. :) – Michael Hampton Feb 27 '13 at 7:38
Thanks for confirming my suspicions though ;-) What I'd have liked would been something like SetVar FOO='bar' in ssh_config ;) – ℝaphink Feb 27 '13 at 7:38

You can set per host config values using .ssh/config file. For example:

SendEnv FOO

Note that server must also support it.

share|improve this answer

Your Answer


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.