Keeping SSH connections alive

Keeping SSH connections alive

By default SSHd will terminate an ongoing connection if there was no traffic (incoming or outgoing) for a while.

If you usually leave remote sessions running for long amounts of time and hate the unexpected disconnects, this behavior can be changed by either enabling the keep-alive feature in the client (if the server accepts it), or enable it in the server directly so it applies to all remote sessions regardless of client used.

ClientAliveInterval 30
ClientAliveCountMax 10

The above two configuration parameters set in the configuration file (usually /etc/ssh/sshd_config) tell the server to send a null keep-alive packet every 30 seconds. In case the client is non-responsive, the server will retry for 10 times before terminating the connection.

Leave a Reply