Depending on how your SSH server or internal firewalls are configured, your SSH session may automatically disconnect after some time. It's possible to configure SSH to send a special packet every certain number of seconds, to keep the connection from idling and becoming a candidate for disconnection. This is useful if you have a service that utilizes SSH, that you do not want to be disconnected. To employ this tweak, we must configure the ServerAliveInterval
setting.
There are two ways of configuring this, one that affects your user account and another that will deploy the setting system wide. First, let's explore how to configure this for your user account.
Remember the ~/.ssh/config
file that we configured earlier in this chapter? Open it up again in your text editor. Here's a sample of this file for your convenience:
Host icarus Hostname 10.10.10.76 Port 22 User jdoe Host daedalus Hostname 10.10.10.88 Port 65000 User duser Host dragon Hostname 10.10.10.99...