December 3, 2009

Keeping SSH Session Alive

Preventing a SSH connection from dropping while you are inactive or waiting for a script to finish is quite easy. If you are on a Ubuntu or Debian client you only have to add one line to

ServerAliveInterval 5

In OSX the config file for ssh can be found in /etc/ssh_config.

Actually this line sends a keep-alive packet to the server every 5 seconds. You can change the interval as you like, but for me it works best with 5 seconds.

Alternatively you can also use the parameter when connecting to the remote host. The command looks like this:

ssh -o ServerAliveInterval=10

Leave a Reply