About nixCraft

Topics

Open SSH Server connection drops out after few or N minutes of inactivity

Posted by Vivek Gite [Last updated: October 16, 2006]

Open SSH Logo

I have already written about how to deny or access to users using OpenSSH. Today I am going to write about another interesting problem.

Basically this is a security feature. Ssh connection freezes or drops out after N minutes of inactivity. According to official OpenSSH man page:

"This is usually the result of a packet filter or NAT device timing out your TCP connection due to inactivity. For security, reason most enterprises only use SSH protocol version 2. This problem only occurred with version 2."

If you work for long hours using ssh and left workstation for some other work, your connection will be dropped by remote server. This may be little annoying to you. So to get rid of this problem:

Open your /etc/ssh/sshd_config file:
# vi /etc/ssh/sshd_config
Modify setting as follows:
ClientAliveInterval 30
ClientAliveCountMax 5

Where,

Close and save the file. Restart sshd:
# /etc/init.d/ssh restart
OR
# service sshd restart

Another option is enable ServerAliveInterval in the client's (your workstation) ssh_config file.
# vi /etc/ssh/ssh_config
Append/modify values as follows:
ServerAliveInterval 15
ServerAliveCountMax 3

Where,

In above example, ServerAliveInterval is set to 15 and ServerAliveCountMax is left at the 3, if the server becomes unresponsive, ssh will disconnect after approximately 45 seconds. Again this option applies to protocol version 2 only.

Read the man pages of ssh, sshd and sshd_config/ssh_config for more information.

E-mail this to a Friend    Printable Version

You may also be interested in other helpful articles:

Leave a Reply

We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Copyright © 2004-2008 nixCraft. All rights reserved - TOS/Disclaimer - Privacy policy - Powered by Open source software.