How-to: Fix SSH Session Timeouts on Mac OSX Mountain Lion.

Recently, we got an upgrade with Comcast that included phone service (does anyone still use land lines at home besides my grandmother?), and increased bandwidth. Increased bandwidth seemed great to me and I could just not use the phone, plus my monthly bill is somehow cheaper this way. Not sure who comcast has working in the accounting department but, I will gladly take the offer.

All was well until after my new service was installed (which included a new upgraded cable modem) I started to notice all of my open ssh sessions were closing if they were idle for just two minutes.  This is very frustrating as I usually have about 3-4 open sessions going at any given time, and I tab back and forth between them all. Every time this happens I need to logon to the remote server once again.

So I started investigating and found out that the NAT State table on my new cable modem will tear down idle TCP connections after 120 seconds. What a pain in the @SS! I am not even sure if Comcast even knows about this problem., but not having much luck with their support in the past I needed to find a way to fix this without them.  The cable modem itself had no configuration options for the NAT state table I could find on the consumer side. I am sure its probably a setting they can see from the providers management interface on the router, but then again… would they even know what I was talking about if I called their “support”?

After some digging around I found out that you can configure an SSH Keep Alive in ssh_config. The trick is to set it lower than your nat timeout. I figured 60 seconds should suffice. The change is very easy to make, here is how you can make this change if you run into a similar situation.

Just edit /etc/ssh_config using your favorite text editor.

vi /etc/ssh_config

Just add the following line to the bottom of your file:

ServerAliveInterval=60

Thats is all there is too it. Now my SSH sessions stay open as long as I need them too.


Posted

in

, , , ,

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *