SPUG: DB connection via SSH tunneling
Jim Flanagan
jimfl at tensegrity.net
Thu Sep 25 17:23:59 CDT 2003
On Thu, 25 Sep 2003, Ken Clarke wrote:
> Here's what I have in mind. They can run Vandyke's VShell behind their
> corporate firewall. VShell can be configured to provide ODBC connectivity
> to any system DSN on the internal LAN. I can create an SSH connection using
> Net::SSH::Perl but this is as far as I get. I have the ODBC connection in
> my left hand and DBI's methods in the right hand. How do I bring the two
> together?
You need to set up a port forward with ssh, then have DBI connect to the
local port. Let's say that the database on the remote machine is running
on port 123. We will set up a local port 9123 on the local machine that
forwards traffic to the 123 on the remote machine over the SSH
connection.
With the command line, that would look like:
ssh -L9123:localhost:123 user at remote
With Net::SSH::Perl, you'd have to use the options parameter to the
constructor to set this up:
$ssh = new Net::SSH::Perl("remote",
options => ["LocalForward 9123 localhost:123"]);
Then you can use DBI to connect to the database on locahost:9123 as
usual.
--
Flanagan::Jim
http://jimfl.tensegrity.net
mailto:jimfl%40t%65ns%65gr%69ty.n%65t
More information about the spug-list
mailing list