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.
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:
:~$ sudo apt-get install autossh
:~$ 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.