I have a Mac laptop and would like to have a persistent ssh tunnel so I can always log in from outside the local network. I'm looking for something that will work when the server can't be reached initially (e.g. if I don't have an Internet connection when I boot it), and will automatically start the tunnel when possible.
I've tried putting an
@reboot autossh line in my crontab, but I've found that sessions started with
autossh disconnect every so often, and
autossh quits if the first attempt fails. My current workaround is a small script and a cronjob:
# crontab /home/blackl/bin/script &! # script #!/bin/sh while true; do ssh -Ngn -R $some_port:localhost:22 $server; sleep 30; done;
Is there a better way to do this, or will I just have to be happy with this for now?