OK, this is a dead easy instruction of setting up a permanent ssh tunnel through cron
This establishes port forwarding to a remote server.
Command
1 2 3 |
crontab -e nc -z localhost <LOCAL_PORT> || ssh <REMOTE_USER>@<REMOTE_HOST> -N -L <LOCAL_PORT>:<REMOTE_IP>:<REMOTE_PORT> & |
Example
1 |
* * * * * nc -z localhost 15432 || ssh a@big-bad-server.net -N -L 15432:10.0.80.1:5432 -L 25432:10.0.80.2:5432 & |
References
1. Serban Simu, Devenie Corliss, Set up permanent SSH tunnel via cron,
https://support.asperasoft.com/entries/20150692-Set-up-permanent-SSH-tunnel-via-cron