Help needed making self repairing SSH tunnel script
The boss at work has asked me to make the wifi available to the public for our customers meaning I am now forced to use what is a completely unsecure connection to do any web browsing. I now use a socks proxy to make a secure ssh tunnel to my home server (named raspberrypi_mobile in my ssh setup) any time I want to go on my work laptop, I wanted to automate the process so it could run in the background and I don't have to bother creating the tunnel every time I use the laptop so I have this script which runs on login (not boot)
This allows time for the laptop to connect to the wireless network and then creates the ssh tunnel
while true; do
ping www.google.com -c 1 && break
ssh -D 2808 raspberrypi_mobile
The problem here is that this only works whilst the network remains connected, as soon as I slightly go out of range or I close the laptop lid or anything that severs the tunnel, it hangs and I'm left with a dead ssh tunnel which I have to manually kill and reinstate to get it back and running.
I'm completely open to suggestions if anyone wants to help me out with this one, there must be a way to alter this script so that if the network goes down the tunnel is closed automatically and then I can loop the whole thing back to the start and await a fresh internet connection to make a fresh tunnel?
Last edited by CaptainMark; July 13th, 2013 at 07:06 PM.
Catch me on Freenode - imark