SOHO : Small Office Home Office
Freeware - Opensource software tips, tricks, tweaks & fixes for managing, securing, improving the performance of SOHO Desktop, Laptop, Networks

Monday, July 12, 2010

How to avoid ssh time outs?


When ssh times out it will terminate or you will get error message
write failed : broken pipe

There are two solutions. One is to configure the SSH server to send a packet to the client, and the other is to configure your SSH client to send a packet to the server. If you have lots of servers, setting it on the client will be easiest. If you connect to a single server from lots of different locations, then setting it on the server will make more sense. Or, you can configure both to do it.

Configure the server
Open up/etc/ssh/sshd_configand find the ClientAliveInterval option (if it’s not there, add it). The value is in seconds, so I went with 180 seconds, or  3 minutes.
ClientAliveInterval 180

Configure the client

Edit  /etc/ssh/ssh_config
and find the ServerAliveInterval option (if it’s not there, add it). Again, this value is in seconds, so a 9-minute interval is 180 seconds.
ServerAliveInterval 180

The default of both of these values is 0, which means no alive packets are sent. Setting them to anything other than 0 makes the SSH server or client send a packet across the encrypted SSH channel every ‘n’ seconds, thus avoid the idle timeout on the router. It has finally resolved my timeout issues, for which I’m very grateful.

No comments:

Post a Comment