Content

blog, portfolio, and links

Fixed: Remote SSH Command Failing

Monday 12 January 2009 - Filed under Default

One great way to use SSH is to run a single command on a remote server like this:

ssh user@host command

‘command’ here can be anything and the text output will be piped back to your local terminal.

I was having a problem with a few servers where this wasn’t working. Turns out the problem was this line in my user’s .bashrc

[ -z “$PS1” ] && exit 0

In this case, the -z tests “$PS1” (the prompt string) for null. Since the prompt was null, .bashrc exited on me. After removing that line, all was fine. If you know a better way to work around this or some very important reason the -z line should stay, feel free to leave a comment.

Tagged: »

2009-01-12  »  David Sterry