SSH remote command not timing out
I provide support to a bunch of remote locations through my job. Unfortunately all the locations are on a regular up and down dial up connection. When sending files/updates to the locations, we are sending the files via scp then kicking off an install script via ssh. Here is my problem:
1. The ssh command kicks off. 2. The ssh command makes the connection and begins the remote script. 3. The connection is lost to the location before it can get a return code back from the ssh/remote script. This causes the ssh command to hang for a long time. Some times upwards of 1.5 hours. I'm wondering what controls this timeout and if there is anything I can do to force the ssh to die quicker. I already know about the ConnectTimeout setting. This only affects making the initial connection to the location, not a drop in the middle of one. We are using ssh version 3.8p1 on SCO 5.0.7 if that helps at all. Thanks for any help, Tim |
More info
I did determine it is finally timing out exactly 2 hours after the ssh command began. I can't find this setting anywhere. I checked ssh settings as well as some TCP settings and can't seem to find it. A process sitting there for 2 hours before it gives up is kind of crazy.
Any suggestions? Thanks, Tim |
What does "cat /proc/sys/net/ipv4/tcp_keepalive_time" say? If it's 7200 (seconds=2 hours) Try:
echo "120" > /proc/sys/net/ipv4/tcp_keepalive_time Also check if the client uses KeepAlive and see if sshd_config has "KeepAlive yes" |
It is a little different in SCO but was set to 7200 as you mentioned. Just for anyone else using SCO, it is called tcp_keepidle and found in /etc/default/inet. I found you are supposed to change this setting using a program called inconfig and not modify the file directly. I found that about 20 minutes ago. I've changed it, just rebooted my box, and am testing it now. I'll let you know what I find out. It looks promosing by the looks of it. Hopefully that will do it.
Tim |
Problem solved
Ok. Got it all figured out and working about as good as I want. First I changed the tcp_keepidle setting down to 300(5 minutes), the minimum SCO allows. This forces the tcp_keepalives to not even start till after 5 minutes. Then I modified the tcp_keepintrvl setting to 10. This starts the sending of a keepalive out ever 10 seconds after the previous mentioned 5 minutes is reached. The tcp_nkeep setting is at 8 which I left alone. This setting tells the tcp to only send 8 keepalives at the tcp_keepintrvl after the tcp_keepidle time is reached. So now my ssh command gives up and dies approximately 6.5 minutes instead of the 2 hours it was taking before. This suits my needs.
Thanks for all the moral support everyone. Hopefully this will help someone else along the way. Tim |
Moved: More suitable in our Other *nix forum.
|
All times are GMT -5. The time now is 06:32 AM. |