How to keep alive SSH outbound connections in OS X

If you want to keep alive the ssh connections you’ve open in OS X, you can edit the file on your mac located here: /etc/ssh_config and modify the line where you find this instruction: ServerAliveInterval. That tells the number of seconds at which your computer will send a null packet to the server in order to keep the connection alive.

By default, that line is commented and the value is zero anyway. You should uncomment the line and increase the value to something bigger than zero. I’ve set mine to 5.

You can edit the file directly in terminal, with admin permissions like this:

sudo nano /etc/ssh_config

You’ll be asked to enter your admin password. Find this line (as it is in default config):

#	ServerAliveInterval	0

and delete the hashtag at the beginning of line to uncomment it and change the zero value to something bigger. Ctrl + O to save the file and Ctrl + X to exit the nano editor.

Leave a Reply

Your email address will not be published. All fields are mandatory.

This site uses Akismet to reduce spam. Learn how your comment data is processed.