Keeping SSH Connections Alive – Ubuntu 14.04

Distro: Ubuntu 14.04 LTS

After upgrading to Ubuntu 14.04 I noticed I was having issues maintaining access to my remote files. While there are good reasons for having SSH connections timeout, I happen to heavily rely on my SSHFS connections on my private network. The fix is quite simple.

To make sure SSH connections are not timing out add two lines to the ssh_config file.

Open terminal and type:

sudo nano /etc/ssh/ssh_config

Enter your password when prompted.

Add the following to the file under Hosts *:

ServerAliveInterval 300
ServerAliveCountMax 3

My additions to the ssh_config file are shown below

Save the changes and restart the ssh server, or reboot the computer to activate the new settings. Now a keep alive message will be sent to the server every 300 seconds. In the event that the server fails to respond three consecutive times, the connection will be assumed lost.

Tagged , . Bookmark the permalink.

Leave a Reply