Permanent SSH Tunnel

"David A. Riggs" <[email protected]> Tue, 20 Sep 2005 22:27:52 -0400
Newsgroups gmane.org.user-groups.linux.morlug
Message-ID <[email protected]>
Due to an unfortunate kludge of an integration project, I need to rely
on an SSH tunnel providing access to a database on another host. The
server will only allow database connections from localhost. I've got an
SSH tunnel set up as follows:

$> ssh -fNL 3306:localhost:3306 user@dbserver

which connects my local port 3306 (MySQL) via the SSH connection
user@dbserver, to port 3306 on dbserver *from* dbserver.

My concern is that this solution is a fragile one, I fear that a network
interruption will sever this connection at some point leaving my local
application stranded from its database. I've not yet observed this, but
I frequently have interactive SSH sessions broken and suspect this one
could be broken as well.

Can anyone suggest a more robust solution to this problem? I don't have
a full grasp of stunnel, but it seems that it could be triggered from
inetd to perform this task perhaps? Could something like runit be used
to reestablish the SSH connection if it fails? Is there some obscure
product that does exactly what I need?

- David A. Riggs <[email protected]>