Via Andy Skelton in 2010, proving once again that great advice is timeless.
With these lines in your SSH config file—usually in .ssh directory in your user home directory—you’ll enjoy a more reliable remote shell session.
# Do not kill connection if route is down temporarily. TCPKeepAlive no # Allow ten minutes down time before giving up the connection. ServerAliveCountMax 30 ServerAliveInterval 20 # Conserve bandwith. (Compression is off by default.) Compression yes