Print

Print


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]>
wrote:
> Is there anyway to support SSH tunneling through a MySQL DSN?
>
> I would like to open a database connection to remote host through
Perl's
> DBI. The remote database is MySQL, but the server hosting the database
does
> not allow outside connections. Instead the systems administrators
suggest
> first setting up a local SSH tunnel, and then making connections to
the
> host. Something this:
>
>  $ ssh -T -L 3306:mysql.example.org:3306 [log in to unmask] &
>  $ mysql -h mysql.example.org
>
> Alas, this option does not work for two reasons. First, I get prompted
for
> my username after the first command and my shell crashes. Second, and
more
> importantly, port 3306 is already in use on my local machine. The
whole
> 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
password
* Run the local end of the tunnel on a free port
* Configure your local client to talk to the local end of the tunnel

Cheers,
-Nate

Email Disclaimer: http://www.co.marin.ca.us/nav/misc/EmailDisclaimer.cfm