Re: Forcing SSH to timout after a certain time if it isn't responding

From: Darren Dunham (ddunham_at_redwood.taos.com)
Date: 11/19/03


Date: Wed, 19 Nov 2003 21:43:18 GMT

In comp.security.ssh andy <andy@wpi.edu> wrote:
> I tried using
> ssh -o BatchMode=yes -o ConnectTimeout=2 <ip.add.re.ss> /bin/true >
> /dev/null

> But it gives me the follwing error:
> command-line: line 0: Bad configuration option: ConnectTimeout

> I looked in my ssh_config file, and also in 'man ssh_config', and i
> didnt see ConnectTimeout mentioned in either place.

> Does this mean I have an older version of ssh? Is there any otehr way
> I can ahceive that functionality?

You could fork a program that would kill the process in 2 seconds. If
it exits, then the kill will just not work.

Something like this. There might be some tweaking needed.

LOOP..
...
ssh -o BatchMode=yes $host /bin/true > /dev/null &
SSH_PID=$!
(sleep 2 ; kill $SSH_PID >/dev/null 2>&1)&

STATUS=wait $SSH_PID

...

The wait should block until the ssh exits, either from a normal exit or
because it's killed.

Of course you probably want to upgrade anyway.

-- 
Darren Dunham                                           ddunham@taos.com
Unix System Administrator                    Taos - The SysAdmin Company
Got some Dr Pepper?                           San Francisco, CA bay area
         < This line left intentionally blank to confuse you. >


Relevant Pages