in reply to Re^2: 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

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;
  • Comment on Re^3: How do you use Net::OpenSSH to query mysql database via ssh tunnel
  • Download Code

Replies are listed 'Best First'.
Re^4: How do you use Net::OpenSSH to query mysql database via ssh tunnel
by salva (Canon) on May 10, 2017 at 06:53 UTC
    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']});