Re: ssh tunneling through a mysql dsn

From: Cloutman, David <DCloutman_at_nyob>
Date: Wed, 25 Jun 2008 09:25:39 -0700
To: CODE4LIB_at_LISTSERV.ND.EDU
There was a quick recipe for doing key based SSH tunneling in the
January 2008 issue of Linux Journal.


---
David Cloutman <dcloutman_at_co.marin.ca.us>
Electronic Services Librarian
Marin County Free Library 

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


On Wed, Jun 25, 2008 at 7:59 AM, Eric Lease Morgan <emorgan_at_nd.edu>
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 username_at_login.example.org &
>  $ 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
Received on Wed Jun 25 2008 - 11:01:00 EDT