Linux Blog


Filed under: Linux Software,Quick Linux Tutorials — at 9:15 am on Friday, December 14, 2012

I’ve written in the past about automatically performing an action when a host comes back online. However, this post is geared towards a more permanent solution than the one time usage connection.

Introducing autossh:

Description-en: Automatically restart SSH sessions and tunnels
autossh is a program to start an instance of ssh and monitor it, restarting it
as necessary should it die or stop passing traffic. The idea is from rstunnel
(Reliable SSH Tunnel), but implemented in C. Connection monitoring is done
using a loop of port forwardings. It backs off on the rate of connection
attempts when experiencing rapid failures such as connection refused.

It is available on most distributions, and even jailbroken iPhones. Its a great utility.

If you want to use it here’s howto:

Install it:

:~$ sudo apt-get install autossh

Run it:

:~$ autossh [host]

That’s pretty much all there is to running it, although if you want to check out all of its features you should read the help file and man pages. If you want you can resume your SSH sessions without using a password, by using the no password SSH login technique.