There was a quick recipe for doing key based SSH tunneling in the
January 2008 issue of Linux Journal.

David Cloutman <[log in to unmask]>
Electronic Services Librarian
Marin County Free Library 

-----Original Message-----
From: Code for Libraries [mailto:[log in to unmask]] On Behalf Of
Nate Vack
Sent: Wednesday, June 25, 2008 8:21 AM
To: [log in to unmask]
Subject: Re: [CODE4LIB] ssh tunneling through a mysql dsn

On Wed, Jun 25, 2008 at 7:59 AM, Eric Lease Morgan <[log in to unmask]>
> Is there anyway to support SSH tunneling through a MySQL DSN?
> I would like to open a database connection to remote host through
> DBI. The remote database is MySQL, but the server hosting the database
> not allow outside connections. Instead the systems administrators
> first setting up a local SSH tunnel, and then making connections to
> host. Something this:
>  $ ssh -T -L [log in to unmask] &
>  $ mysql -h
> Alas, this option does not work for two reasons. First, I get prompted
> my username after the first command and my shell crashes. Second, and
> importantly, port 3306 is already in use on my local machine. The
> thing seems weird anyway.

Yeah -- this is (probably) the way you want to do it, though. You'll
need to:

* Set up SSH keys such that building the tunnel doesn't prompt for a
* Run the local end of the tunnel on a free port
* Configure your local client to talk to the local end of the tunnel


Email Disclaimer: