To mount persistent SSH tunnel, nothing is better than autossh
. But there is a small inconvenient, it doesn’t really like being started in a runlevel (go figure why). The solution is to use the /etc/rc.local
file for this task:
autossh -i /foobar/.ssh/id_dsa -L 83:192.168.3.32:80 root@moya.farscape.net -oBatchMode=yes -N
Here we make a persistent tunnel with a forwarding of local machine port 83 to the moya.farscape.net machine port 80, using the user foobar key to initialize the connection. autossh
will monitor the ssh tunnel and restart it as needed.