ConnectTimeout=2 not working for me

Damien Miller djm at mindrot.org
Fri Dec 25 11:15:43 EST 2009


On Thu, 24 Dec 2009, Vahid Moghaddasi wrote:

> Hi all,
> 
> I have somewhat a strange problem that I could not figure out, maybe someone
> here can lelp.
> 
> I have a script that uses scp to distribute files to many servers, I use '-o
> BatchMode=yes -o ConnectTimeout=2 options so the scp will not get stuck if
> something is wrong with the remote host.

For some time, ConnectTimeout has applied to both the TCP connection and
the first exchange of the protocol (banner exchange). This should allow
a client to detect a fully stuck server. Are you running a recent version
on the client or just the server?

> If the remote host is down (non-pingable) or sshd is down the timeout option
> works and the scp continues to the next host in 2 seconds, but if the host
> is up (pingable) and sshd is listening on port 22 and host is either in
> trouble e.g. irresponsive then ssh connection hangs and wont every timeout.
> 
> In that case, I will have to logon to the server initiating the scp and kill
> that process so the script will continue to run.
> 
> Is there any option that I can use to just disconnect the scp connection in
> a given time, regardless of the scp is actually transferring file or not so
> the connection wont hang for ever? The actual transfer time is about 5
> seconds. I have just upgraded ssh to 5.2p1 but no help. The remote servers
> platforms are AIX, Linux and Solaris and I see this behavior on all at some
> point.

You could probably shell script a timeout to unconditionally kill the scp
process after a certain amount of time. 

-d


More information about the openssh-unix-dev mailing list