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!

Multiple terminals in a single SSH session

When I sit to work, I am using linux terminals 95% of the time. And I tend to use lots of them. One for vim, another for compiling and testing, another for checking whatever files the program outputs, and so on… If you’re a multiple windows/tabs kind of guy (or gal, why not?) like me, you know what I am talking about!

Ctrl + Shift + N is my favorite shortcut ever on gnome-terminal, but when I am not physically on the machine but working via SSH, it is not nearly as fun. In fact, it is annoying as hell as it opens a new local terminal, and I have to log in again, go to the path I am interested in, and only then being able to do whatever I want to do (which, sometimes, is pretty quick and I end up closing the terminal, just to regret next time I need it again). Thankfully, I found a nice way to solve this!

Read the rest of this entry »