Avoiding SSH timeouts

I use SSH a lot, and it is a pain when my session times out. This often happens when I step away from the task at hand for a couple minutes. Most of the time, this task is editing a file in vim, and I end up having to restore the file, delete the swap file, etc. Not fun.

My solution for a while was to use screen. This way, I reconnect and continue where I stopped. Better, but the timeouts are still annoying as my terminal becomes unresponsive and I have to close it and reconnect on a new one.

So I decided it was time to solve this. Turns out a simple Google Search found the solution on this blog, and it is dead simple:

Edit your ~/.ssh/config file and add a line containing ServerAliveInterval 60. This sends a keep-alive packet every 60 seconds, which is more than enough to keep your connection from timing out.

Painless, right? Now go and configure your machine, too!


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: