Categories
Linux

Prevent SSH session to a server from disconnecting

Prevent SSH session to a server from disconnecting

If you need to connect for example to a web server by using SSH, you might have encountered that sometimes the SSH session becomes unresponsive, because the connection has timed out and disconnected. This migth happen, if you haven’t typed anything in the terminal in a while (for example you reading some documentation at the same time). There’s an easy fix for that. We need to add the following to /etc/ssh/ssh_config file:


# Keep connection alive by sending a packet every 10 seconds
ServerAliveInterval 10

 

Sources:

I found the following thread on StackExchange useful for fixing this problem.

https://apple.stackexchange.com/questions/36690/how-can-i-prevent-an-ssh-session-from-hanging-in-os-x-terminal