Auto start an SSH tunnel and keep alive
I have a program that needs to talk to another server, but to secure the traffic I've set up a port forwarding SSH tunnel. The only problem is that this tunnel needs to be kept alive and started when the server boots up. Here is how, using
/etc/inittab
For the server you want to make connections from follow these instructions.
Open up
/etc/inittab
and insert this code somewhere near the bottom
# Keeps an SSH port forwarding connect between serverA <---> serverB for mysql sm:345:respawn:/usr/bin/ssh -N -L 3307:127.0.0.1:3306 -l admin 192.168.1.5
Let's break it down
<
ul>
For those familiar with SSH, it should go without saying that you need to set up pre-shared keys to automatically log into the remote server
Comments
Post new comment