Keeping Your ssh Connection Alive
You may have had the experience of having your SSH connection to another machine drop if you ignore it for too long. Which can be irritating, especially if it's (say) your e-mail.
You can fix this using the SSH config option ServerAliveInterval. SSH options can be set on the command-line (with the -o option), or by editing your ~/.ssh/config or /etc/ssh_config files. Note that SSH uses the first setting that it encounters for an option, and it reads command-line options, then per-user config, then the global config, and general/default ones at the end.
Add this to your ~/.ssh/config file to turn ServerAliveInterval on for all SSH connections:
Host * Protocol 2 ServerAliveInterval 60 |
ServerAliveInterval sends a package through the encrypted channel, after the specified number of seconds of inactivity, to the server, requesting a response. It's turned off by default, and you may need to experiment a little with the value. However, once you have the value set to work with your system, you should be able to keep your SSH sessions connected.
Note: Most systems will have TCPKeepAlive on by default. This sends a TCP package after a period of idleness, usually two hours. This is often too long an interval to prevent disconnection; and TCPKeepAlive packets can also be spoofed, unlike ServerAliveInterval.
Read more on "Tips of the Trade" »

Managing a mixed IT infrastructure is always a challenge. The challenge is compounded for mid-sized companies where you don't have the staff resources of larger firms. A variety of systems and equipment creates a complex infrastructure where finding and solving performance and network glitches is really difficult. Learn how Hitachi IT Operations Analyzer can help.