When logging in to my Mountain Lion Mac remotely via ssh I do not get the same PATH variable as when I open a shell locally: The local shell inherits its environment as expected from launchd and therefore has the PATH value I set in /etc/launchd.conf.

With the remote shell I hit a surprise: When I open a shell via ssh it does not inherit the environment variables set in /etc/launchd.conf although the related ssh processes all have launchd as their parents. Why???

A cut from a ps -ef output shows:

  0     1     0   0 Mon01PM ??         9:07.07 /sbin/launchd
501   150     1   0 Mon01PM ??         0:17.99 /sbin/launchd
501 39994   150   0 Thu11AM ??         0:00.72 /usr/bin/ssh-agent -l
  0 74002     1   0  2:08PM ??         0:00.05 /usr/sbin/sshd -i
501 74005 74002   0  2:08PM ??         0:00.00 /usr/sbin/sshd -i
501 74000  9844   0  2:08PM ttys000    0:00.02 ssh [email protected]

I can fix the issue by setting PATH e.g. in .bashrc, but I'm in search for a way to give the same PATH to all applications launched under Mountain Lion (see In Mountain Lion how do I set the PATH environment variable...).

So my question is: Why do remote shells via ssh do not inherit the launchd environment?

1 Answer 1


I've looked for an answer too and eventually found a related answer to this question, How to set system-wide environment variables on OS X Mavericks.

It is a security measure, particularly to ensure secure shell users with a disabled shell, where SHELL is set to /bin/false, cannot gain unsolicited access.

One workaround is settting PermitUserEnvironment in your ssh config; please read security caveats in above mentioned answer before doing this.

  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes.
    – grg
    Commented Jun 8, 2014 at 7:10
  • Good idea: I've just tried to add this info from the other answer in - but it needs to be peer reviewed...
    – halloleo
    Commented Jun 10, 2014 at 7:15
  • Peer-review passed - answer now more helpful. :-)
    – halloleo
    Commented Jun 16, 2014 at 9:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .