in reply to Re^4: Establishing SSH tunnel and opening another SSH connection through it
in thread Establishing SSH tunnel and opening another SSH connection through it

That happens because requesting password authentication disables the authentication agent.

The solution is just to not ask for password authentication in the gateway:

my $ssh_gw = Net::OpenSSH->new($gw); # no password given, authenticate # using public key on the gateway my $proxy_command = $ssh_gw->make_remote_command('nc %h %p'); my $ssh = Net::OpenSSH->new($host, password => $password, # request password +authentication master_opts => [-o => "ProxyCommand=$proxy +_command"]);
  • Comment on Re^5: Establishing SSH tunnel and opening another SSH connection through it
  • Download Code

Replies are listed 'Best First'.
Re^6: Establishing SSH tunnel and opening another SSH connection through it
by tehcook (Initiate) on Feb 09, 2012 at 19:47 UTC
    That was it ! I was pretty sure that ProxyCommand goes by itself, is non-interactive and uses only public key. And whatever is requested in OpenSSH->new() applies to the destination host. Thank you for help