Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

This is my /etc/environment:


Now I check that the environment is being set when connecting via ssh:

ssh foobar@my_host env

And this is the output:

SSH_CLIENT=foobar 46460 56723
SSH_CONNECTION=foobar 46460 foobar 56723

So: why is HELLO not being set? Is /etc/environment being parsed at all in Ubuntu? What is the recommended way to set system wide environment variables in Ubuntu?

And as bonus, it would be great if those system wide environment variables work when doing:

  • ssh (non-interactive commands)
  • ssh (interactive commands)
  • cron jobs
  • interactive login shells
  • and what-not

I mean, when I am thinking about system-wide environment variables, I really mean it!

I do not need a different method for each possible way I have to get into my machine: I just need one method, which works for all users, all commands, all login mechanisms: what could be simply described as a "system-wide setting".

Sorry for the ironic mode, but I have just been losing (again) some time with this issue.

share|improve this question
up vote 0 down vote accepted

Make sure you have added as a session module in /etc/pam.d/common-session. See also the manual of pam_env. Also make sure SSH uses PAM (UsePAM=yes in /etc/ssh/sshd_config).

share|improve this answer
I have added the line session required to /etc/pam.d/common-session, and verified that my ssh server is using PAM (UsePAM yes). It is still not working. I have even restarted the SSH server, but I had no luck. Any idea? – jeckyll2hide Sep 5 '11 at 15:04
I think I got bitten badly by a quirk in my own setup: I am using ssh connection sharing, and of course no authentication is performed as long as an open connection is still there. So I had to kill all opened connections to the remote host, and reconnect from scratch. Now /etc/environment is being read as expected. – jeckyll2hide Sep 5 '11 at 15:47
@gonvaled: Theoretically, the PAM session stack could be ran for every new session -- it usually doesn't depend on the auth stack in any way. It's just that OpenSSH devs chose to open a single PAM session per connection. – grawity Sep 5 '11 at 16:54

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.