Wednesday, March 4, 2009

How to confuse ssh

I'm sure there are lots of ways to confuse ssh, just like there lots of ways to confuse me. But this is the one i found.

At work we run Solaris with lots of old tools. I end up building lots of new stuff for my self and then having to work around the old ones. When I worked in a Irix shop, I had to do the same thing but for different reasons.

One of the oddities that I run into is that our login shells are often csh. I like bash or ksh in a pinch. Well this means that I had to hack together a .cshrc that checks for bash and then execs it, leaving me with a perfect world of bash.

It looks something like this:

if ( $_ == "/bin/which" || $_ == "/usr/bin/which" ) then
set which="true"

set BASH = "$PWD/bin/bash"

if ( -x $BASH && $which != "true" ) then
exec $BASH

set BASH = "/usr/bin/bash"

if ( -x $BASH && $which != "true" ) then
exec $BASH
Well ssh does not like this for executing remove commands. When a login shell does that it confuses remove commands but not the remove login one.

For example running: ssh removeserver date would just hang. The debugging output would even say: debug1: Sending command: date then just stop. Unless you add the -t option then it would drop you into a shell.

Very confusing and frustrating, especially when mixed with ProxyCommand and netcat which just does nothing. Or running ssh -t remoteserver ssh nextserver which just drops into a shell on the remoteserver. Then hair pulling occurs :)

I updated to exit before running the bash shell for certain hosts:
if ( `hostname` == 'remoteserver' ) then
Lets just say that it made my afternoon quite unpleasant until I found the solution.

No comments:

Post a Comment