Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^2: How do you use Net::OpenSSH to query mysql database via ssh tunnel

by salva (Canon)
on May 09, 2017 at 14:57 UTC ( [id://1189914]=note: print w/replies, xml ) Need Help??


in reply to Re: How do you use Net::OpenSSH to query mysql database via ssh tunnel
in thread How do you use Net::OpenSSH to query mysql database via ssh tunnel

Net::OpenSSH does not directly supports creating TCP redirections, but they can be created using ssh forward control command:
$ssh->system({ssh_opts => [-O => 'forward', '-L4022:localhost:22']})

Replies are listed 'Best First'.
Re^3: How do you use Net::OpenSSH to query mysql database via ssh tunnel
by haukex (Archbishop) on May 09, 2017 at 18:52 UTC

    Thanks! If I understand correctly, with this command, the tunnel just stays open as long as the master process is running?

    Revised code:

    use Net::OpenSSH; my $ssh = Net::OpenSSH->new($host); die $ssh->error if $ssh->error; $ssh->system({ssh_opts => ['-O','forward', '-L127.0.0.1:12345:127.0.0.1:3306' ] }) or die $ssh->error;
      Yes, it will stay open until the master process finishes or you ask it to close the tunnel sending a cancel control:
      $ssh->system({ssh_opts => ['-O', 'cancel', '-L127.0.0.1:12345:127.0.0. +1:3306']});

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1189914]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (4)
As of 2024-03-29 11:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found