Tuesday, 17 January 2012

ssh hostnome `filename` doesn't work due to PATH

Fresh installation of Ubuntu and the remote machine won't
run scripts in ~/bin

ssh remotemachinename `echo $PATH`

showed ~/bin was not in the path for remote sessions but was when a log in was performed.

It appears that .bashrc is not executed in the same way with a remote command.
Adding, `echo 'in .bashrc'' to the top of the remote ~/.bashrc shows it IS
executed on remote command on the working machine.

Then: I noticed `ls` and 'ls' generate different results. `ls` appears to run remotely as hoped; 'ls' appears to do something on the remote machine and the local one.

Perhaps I should use speech marks. They behave ok. Anyway....

Since .bashrc is being executed ok remotely, I think there's something in it preventing the path being set as expected for remote commands. A check showed
the working machines had line 6 of the default .bashrc commented. This line
exits, doing nothing for a non-interactive shell.

So, should the path be set elsewhere for non-interactive shells? Is this a security measure or a logical one?

No comments:

Post a Comment