I'm looking for a reliable way to start a secure tunnel at boot on a laptop.
This tunnel will not be needed by other parts of the boot process, but could be needed at any subsequent time by a user. It should "just work", the user should not have to monitor and fix it.
The secure tunnel will "pull in a port" from a insecure application bound to localhost (in this case, a redis database) on a remote server to the ubuntu laptop.
remote server: example.net
remote port to forward: 6379, bound only to localhost from example.net
remote user: email@example.com
keyfile: firstname.lastname@example.org has authorized a ssh keypair with no passphrase, one key is stored in authorized_keys on the server and the other in /root/moleKey.rsa on the laptop
This works inside a terminal window on the laptop:
$ sudo su ... # ssh -i /root/moleKey.rsa -L 16379:localhost:6379 email@example.com -N & # exit $ telnet localhost 16379 (works fine) ^C
So then I tried putting
ssh -i /root/moleKey.rsa -L 16379:localhost:6379 firstname.lastname@example.org -N &
But that doesn't work reliably, the ssh process was gone when the tunnel was needed and I can't find any error lines for it in syslog or messages
Is there a more reliable way to start the secure tunnel at boot-up, or perhaps a manager that will restart the secure tunnel as needed?