Keeping an idle SSH connection alive

One of the servers which I login to on a regular basis has the annoying habit of dropping any SSH connections where there has been no activity for more than 3 minutes. Having to repeatedly reconnect is frustrating, especially if I’m leaving a script running.

Fortunately, there’s a simple solution in the form of two configuration options:

  • ServerAliveInterval X: Request a response from the server if no data has been received for X seconds.
  • ServerAliveCountMax Y: Disconnect if more than Y requests have been sent to the server without receiving a response

If responses are not received from the server, the connection will be terminated automatically after X * Y seconds.

Leave a Reply

Your e-mail address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.