Sunday, September 20, 2009

Preventing Inactive SSH Snapping

Sometimes we face issues like very frequent connection breaks in the ideal SSH sessions,and its mostly because of "a packet filter or NAT device timing out your TCP connection due to inactivity."
http://www.openssh.com/faq.html#2.12

So here is the work around for the same.

Linux :
1] Open following file /etc/ssh/ssh_config (as Root user).
2] Append the following line in there at the bottom.
3] ServerAliveInterval 60
4] Save the file.
5] Restart the sshd daemon.
6] The line entered have the following definition.
ServerAliveInterval
Sets a timeout interval in seconds after which if no data has been received from the server, ssh
will send a message through the encrypted channel to request a response from the server. The
default is 0, indicating that these messages will not be sent to the server. This option applies
to protocol version 2 only.
Source :man page of ssh_config [man 5 ssh_config]


Windows [Putty] :
1] Open Putty.
2] Select a session,load the settings using 'LOAD'.
3] Set protocol to SSH and port number to 22 [if not default].
4] Under the 'Connection',option in the left hand side tree.
and set value of 'Seconds between Keepalives' to 60 [Default 0].
5] Also set Preferred SSH protocol version to '2' under Connection->SSH.
6] Save the settings,under Session.
7] Open up a new 'Break free' session now.
8] The 'Keepalives' are a special kind of messages sent to the server sent over SSH.As mention above by SSH manual.

Cheers...

0 comments:

Post a Comment