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. 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. Thank you,
I'll be honest, I've never had much luck with scp. It freezes, alot. I always recommend: cd dir; tar czf - dir | ssh user at host "tar xzvf -" or cd dir; ssh user at host "tar czvf -" | tar xzf - On Thu, Dec 24, 2009 at 1:31 PM, Vahid Moghaddasi < vahid.moghaddasi at gmail.com> 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. > > 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. > > Thank you, > _______________________________________________ > openssh-unix-dev mailing list > openssh-unix-dev at mindrot.org > https://lists.mindrot.org/mailman/listinfo/openssh-unix-dev >
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
Try using ServerAliveInterval=3 and a reasonable ServerAliveCountMax as well. The full TCP handshake could be happening but then sshd might not be doing anything with the established tcp connection. ConnectTimeout will only bail if there is a problem setting up the connection. Once the connection is established ConnectTimeout's job is done. On Thu, Dec 24, 2009 at 1:31 PM, Vahid Moghaddasi < vahid.moghaddasi at gmail.com> 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. > > 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. > > Thank you, > _______________________________________________ > openssh-unix-dev mailing list > openssh-unix-dev at mindrot.org > https://lists.mindrot.org/mailman/listinfo/openssh-unix-dev >