onsdag den 8. september 2010

How to keep your SSH connections from dropping/freezing

I have been using SSH connections from PC's for years without any problems but after switching to Mac they started getting dropped or froze after a period of inactivity.

The problem occurs because my routers NAT closes the connection after a while of inactivity resulting in the connection to freeze and later to drop.

A little research gave this solution:

ssh -o ServerAliveInterval=60 [email protected]

The ServerAliveInterval=60 option will send keep alive package every 60 seconds and stop the routers NAT from closing the connection.

Instead of typing "-o ServerAliveInterval=60" every time you can add the following to the file ~/.ssh/config

ServerAliveInterval 60

Tested on Mac OSX 10.6.4 with OpenSSH_5.2p1 but should work on any system with OpenSSH_3.8p1 or newer. This solutions does off course not eliminate dropped connection due to bad connections.

Ingen kommentarer: