Keep your SSH sessions alive

When part of your job entails connecting to many different machines over SSH it’s common to leave sessions open for later use. Unfortunately with the default settings you’ll often find yourself navigating back to a terminal window only to find it locked up or spitting out a Broken Pipe error.

Fixing this problem is simple, you just need the correct line in ssh_config to have your machine send continuous keep-alive traffic to the servers you’re connected to.

The relevant line is:

ServerAliveInterval 60

The interval is denoted in seconds, so with this exact line your box will be sending a keep-alive packet every minute to the servers it is connected to via SSH. You can of course change this to any number of seconds, if you have very low bandwidth you may consider bumping it up to 4 or 5 minutes to keep the network cost lower.