SSH session timeouts

Recently I’ve experienced some odd SSH behavior, my connection is lost after not issuing a command for a while. Usually I get this message:

ME@SERVER:~% Read from remote host SERVER: Connection reset by peer
Connection to SERVER closed.

Nice, indeed. However, this can be fixed by creating the file ~/.ssh/config and pasting this into it:

TCPKeepAlive no
ServerAliveInterval 15

What happens here is that you overwrite the default SSH configuration usually found in /etc/ssh/ssh_config with a different behavior. A timeout interval is set after which your SSH client will request a response from the server. This is usually done via TCP keep-alive, which is unreliable (and insecure) and therefore turned off. So, no more timed-out connections here, great! Feel free to read the ssh_config manpage for more insight.

2 thoughts on “SSH session timeouts

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s