I have an Alpine docker container and depending on how I connect using ssh the path is different. If I connect using a PTY shell:
ssh root@localhost sh -lc env | grep PATH
this prints:
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
However if don't use this shell:
ssh root@localhost sh -c env | grep PATH
this prints:
PATH=/bin:/usr/bin:/sbin:/usr/sbin
Why is this happening? What do I need to do so that the second command produces the same output as the first command?
I'll answer my own question. This stack overflow post has the main info needed: Where to set system default environment variables in Alpine linux?
Given that, there are two alternatives:
Declare PATH
using the ENV
option of the Dockerfile
Or add PermitUserEnvironment yes
to sshd_config
file and define PATH in ~/.ssh/environment