Just thought I’d document this for web-posterity…
Some of our systems rely on a large number of environment variables that get loaded via .profile or .bashrc, but most importantly the PATH variable.
Under Ubuntu and Fedora 9+ this stopped working when using “ssh <host> <command>”.
After much googling and head scratching, I finally found the cause.
Our bashrc files all had something like this near the start:
if [ -z "$PS1" ] ; then return # or exit or something fi
Using OpenSSH’s ssh in command mode, e.g. ssh dev-strat stophost, results in a non-interactive login, for which “PS1” is not set.
So if you’re having a hard time getting your ssh commands to load their environment… Check for that.