September 7 2011
Server Tip: Better SSH Timeouts
I recently had an issue with my SSH connections timing out quickly. At Starbucks, I had no issues, but at home, the connection timed out faster than usual.
First, I wanted to see how fast, so I wrote a short bash script that sleeps for increasing periods of time. I found that the connection timed out after five minutes.
I tried creating a ~/.ssh/config file and telling the connection to stay alive: TCPKeepAlive yes. No luck, because the default time period is two hours.
Instead, I ignored the TCP connection’s state and told the SSH client to send a null packet every twenty seconds to keep the connection alive. The SSH client times out if it doesn’t receive a server response after ten packets.