I manage several cloud servers via SSH, but after upgrading my main desktop to Ubuntu 16.10 (from Ubuntu 16.04), I observed that those (SSH) sessions would freeze just after a few seconds of inactivity, even right in the middle of editing a file.
I figured that the servers were not the problem, because that has never happened before, and the fact that it didn’t matter what Linux distribution the remote server was running. So there must have been a change in the default client configuration that was causing the problem.
Startpage to the rescue, which led me to this article. The fix offered by the author in that article is for Mac OS X, but it works just as well on any Linux distribution, with one less command to execute.
The fix is to set values for ServerAliveCountMax and ServerAliveInterval for the SSH client, which you do in a configuration file in the .ssh directory of your home folder. So create and open the file using the following command:
# Change to the .ssh directory under your home folder cd ~/.ssh # Create and open a config file sudo nano config #
Then add the variables and their values in the following code block to it.
# Sets number of server alive messages which may be sent without ssh receiving any messages back from the server. ServerAliveCountMax 3 # Timeout interval (in seconds) after which if no data has been received from the server, ssh will send a message # through the encrypted channel to request a response from the server. ServerAliveInterval 5
Close the file. That should solve your freezing SSH session issues. No need to adjust the file’s permissions, because the default is good enough. For more information about those and other variables, consult the manual page using man ssh_config.