DEV Community ๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ป

DEV Community ๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ป is a community of 970,177 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

Create account Log in
Johnneylee Jack Rollins
Johnneylee Jack Rollins

Posted on

Fixing MacOS' SSH $PATH missing /usr/local/bin

Originally published to https://johnneyl.ee/writes/

Alt Text

Problem: /usr/local/bin missing from ssh $PATH

bash: docker: command not found

Exec ssh [localhost](http://localhost) docker

Normally, your paths include your /usr/local/bin, however, in macos you'll find that if you SSH into localhost (or indeed any macos host), it is missing. Such is the case when setting up a docker profile with an ssh-based remote host, for example. ๐Ÿ™„

To fix this, we need to safelyโš ๏ธ enable an option that's disabled in your sshd_config called PermitUserEnvironment

Solution: /etc/ssh/sshd_config & PermitUserEnvironment PATH,LANG

Edit sshd_config & ~/.ssh/environment

sed -i '' 's/#PermitUserEnvironment no/PermitUserEnvironment PATH,LANG/g' /etc/ssh/sshd_config

Bash:

echo "PATH=/usr/local/bin:$PATH" >> ~/.ssh/environment

Fish:

echo "setenv PATH /usr/local/bin:$PATH" >> ~/.ssh/environment

Conclusion:

๐Ÿฅณ ssh [localhost](http://localhost) docker works!๐Ÿฅณ

Now go and cluster all your macbooks together with docker! ๐Ÿฅณ

Top comments (0)

๐ŸŒš Friends don't let friends browse without dark mode.

Sorry, it's true.