Help2Go.com

Keep SSH session alive on Mac OS X

by Oscar Sodani
March 25, 2008
Sometimes we come across little annoyances that have a quick fix. For me, one such annoyance was that whenever I started an SSH session to my server, in Terminal or iTerm, on Tiger or on Leopard, the SSH session would time out within a few minutes. Drove me crazy!

There is a simple fix to this: you should have a .ssh directory in your home directory. Create a file in there called "config", if it doesn't already exist. In the file, put the following two lines:

ServerAliveInterval 300
ServerAliveCountMax 3

Save the file, and reconnect via SSH to your server or whatever. This time, the session should stay alive for as long as necessary. My sanity was saved.