How to keep your ssh session always alive

The problem is that there is something (usually a firewall or load-balancer), which is dropping idle sessions. If you configure session keepalives, the keepalives will prevent network devices from considering the session as idle.

Linux / Unix / Cygwin OpenSSH fix:

The simplest fix is to enable ssh client keepalives; this example will send an ssh keepalive every 60 seconds:

ssh -o "ServerAliveInterval 60" <SERVER_ADDRESS>

If you want to enable this on all your sessions, put this in your /etc/ssh/ssh_config or ~/.ssh/config:

ServerAliveInterval 60

For more information, see the ssh_config manpage

For Windows user(Putty)

Save this to your PuTTY “Default Settings”…

  1. Click on Connection
  2. Type 60 into “Seconds between keepalives”
Putty Session keep-alive setting

you're currently offline