Keeping an SSH connection alive

This setting should only be configured on the SSH client side:

In your ~/.ssh/config we’ll utilize the ServerAliveInterval setting.

ServerAliveInterval
      Sets a timeout interval in seconds after which if no data has
      been received from the server, ssh(1) will send a message through
      the encrypted channel to request a response from the server.  The
      default is 0, indicating that these messages will not be sent to
      the server.  This option applies to protocol version 2 only.

This setting tells the client to send a keep alive packet at a certain interval to the server, ensuring the connection stays open.

Host example
  Hostname example.com
  ServerAliveInterval 30

That setting will send a packet every 30 seconds if the connection goes idle. Now this is the desired functionality that I’d like to see for all of my SSH connections so we can add it to the host wildcard like so:

Host *
  ServerAliveInterval 120