I have two OpenSolaris servers. The remote server has a MySQL database. MySQL is configured with skip-networking; so, I can't access that database from the first server by simply using the hostname and port.
I must have an ssh tunnel setup to connect to MySQL from the local server. I can do this with a simple : ssh -L 3350:localhost:3306 user@server and SSH keys. It works great.
However, I need the connection to be permanent and preferably run on bootup as well.
I've created a little bash script to create the connection. However, it simply connects, ends the script, and loses the ssh connection. If I modify the script to run a command on the remote server and and a sleep command, it will stay connected for X seconds. I can then connect with MySQL. However, I will surely lose the connection after X seconds.
Does anyone have suggestions for a more elegant way to do this? Is there someway to use Solaris' svcadm to create the connection and maintain it at all times?
UPDATE : I've discovered that if I add sleep X and then create the MySQL connection before X expires, the ssh connection stays up indefinitely. However, that is not a very stable solution. If I lose the database connection, the ssh connection dies and then I'll be stuck without being able to connect again.