How to keep SSH connections alive putty

Soa Technology

How to keep SSH connections alive putty

KEEPING SSH CONNECTIONS ALIVE

Depending on your hardware and software configuration, you may experience SSH connectivity issues. For example, some types of firewalls may preemptively close connections after a certain amount of time has elapsed.

To work around these types of problems, you can adjust your SSH client’s settings. Follow the appropriate procedure below for your own operating system.

Windows operating systems

Microsoft Windows operating systems use the PuTTY program to establish SSH connections. If you experience connectivity issues, you can adjust PuTTY’s configuration to help keep connections alive. To do this, follow these steps:

  1. Start PuTTY.
  2. Load your connection session.
  3. In the Category pane, click Connection.
  4. Under Sending of null packets to keep session active, in the Seconds between keepalives, type 240. With this configuration, PuTTY sends a packet to the server every 240 seconds (4 minutes) to keep the connection alive.
  5. In the Category pane, click Session.
  6. Click Save.
  7. Connect to your account and monitor the connection. If it stil drops, gradually decrease the keepalive interval until the connection is stable.
Linux and Mac OS X operating systems

On Linux and Apple Mac OS X operating systems, the ~/.ssh/config file enables you to specify many SSH settings, including those that keep alive an SSH connection. To do this, follow these steps:

  1. Use your preferred text editor to open the ~/.ssh/config file on your local computer. If the .ssh directory or the config file do not exist, create them.
  2. Add the following lines to the config file. The Host value can be any name you want; it is simply a label for the other settings. The Hostname value is the remote host you want to access; replace example.com with your domain name. Replace usernamewith your own A2 Hosting account username: Host example Hostname example.com Port 7822 User username ServerAliveInterval 240 ServerAliveCountMax 2
    • With this configuration, the SSH client sends a packet to the server every 240 seconds (4 minutes) to keep the connection alive. If the client does not receive a response after two tries (as specified by the ServerAliveCountMax setting), it closes the connection.
    • For detailed information about all of the SSH configuration settings available, type man ssh_config at the command line.
  3. Save the changes to the config file.
  4. Connect to your account using SSH. To do this, simply type ssh example where example represents the Host value you specified in step 2.
  5. Monitor the connection. If it still drops, gradually decrease the ServerAliveIntervalsetting in the config file until the connection is stable.


Leave a Reply