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: Sets a timeout interval in seconds (30) after which if no data has been received from the client, sshd will send a message through the encrypted channel to request a response from the client. The default is 0, indicating that these messages will
not be sent to the client. This option applies to protocol version 2 only.
- ClientAliveCountMax: Sets the number of client alive messages (5) which may be sent without sshd receiving any messages back from the client. If this threshold is reached while client alive messages are being sent, sshd will disconnect the client, terminating the session.
Close and save the file. Restart sshd:
# /etc/init.d/ssh restart
# 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 : 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.
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.TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!
- 30 Cool Open Source Software I Discovered in 2013
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012
- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop