I use a notebook for everything, including checking email, including in public wifi spots. As a result, my email and messenger are permanently configured to send and receive email/messages through an SSH tunnel:
Code:
# ssh -q -f -N -C -T -p $port $user@$basehost -L 225:domain.com:25 -L 2110:domain.com:110 -L 2456:messenger.hotmail.com:1863 -L 2459:gateway.messenger.hotmail.com:1863
That thing above is part of a script I run manually about a minute after booting my machine. And I also have to run it manually every two or three hours, because the tunnel goes down after a while.
How can I automate that? I would like to have it:
- run on boot
- check if the (usually wifi) connection is already available
- create the tunnel
- postpone it if no connection is available yet
- do nothing if the tunnel already exists and is up/responsive, so it can be run on cron every 30 or 60 minutes
Honestly, I think I can only go as far as running it on boot. I need help with all the rest. :-\