Last Updated: February 24, 2016
·
2.289K
· leucos

How to load environment when using ssh non-inteactive

When you want to load your environment (.profile for instance) when executing a remote command with ssh, you can prefix your key in .ssh/authorized_keys with a commnd snipet like this :

command=". ~/.profile; if [ -n \"$SSH_ORIGINAL_COMMAND\" ]; then eval \"$SSH_ORIGINAL_COMMAND\"; else exec \"$SHELL\"; fi" ssh-dss AAA...

...all on one line.