Table of Contents

How to keep your SSH connection alive when idle

Motivation

This is something I regularly need and I always Google it so better write it down here.

Sometimes you want your SSH session development session to be alive for longer idle periods and relogging loses the thought pointer slowing down work.

The solution

This is easy to achieve, just add this to your ~/.ssh/config:

Host myhost_to_connect_to
    HostName 1.2.3.4
    ServerAliveInterval 60

This sends activity to the ssh session every 60 seconds and should keep your sessions active.

Also remember

Many times there is a reason to shut down idle connections, mostly due to security. Se be aware of these and do not use persistant connections in an insecure environment.