SSH connection timeouts

Should you’ve ever suffered from SSH automatic disconnection when you establish an SSH session to a server, this is due to a lack of activity between the server and the client. In most cases, the firewall that sits between them cuts the connection.

You can however force either the SSH client or the server to keep the session alive in these cases by sending KeepAlive packets to the other end.
On the client side you have to set the

ServerAliveInterval N

variable in the /etc/ssh/ssh_config file where N is the number of seconds between each KeepAlive packet (120 should do).

Whether we want to have this behaviour on all the SSH connections to a specific server we better configure the server to keep the sessions open saving us to tweak each client’s configuration. Do this by adding:

ClientAliveInterval N

in the /etc/ssh/sshd_config file.


1 thought on “SSH connection timeouts

Leave a Reply

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

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

Google photo

You are commenting using your Google 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 )

Connecting to %s