in reply to How to open nested SSH connection using perl

Hello gjoshi,

Although the Monks seems that they have provided you with many solutions, I would like to add a few references where you can get some information with samples of code, for easier implementation.

I had the same problem with you some time ago and I found the most common name is ssh multi hop, when describing what you are trying to achieve. So ref1 Transparent Multi-hop SSH and ref2 SSH Port Forwarding Through Multiple Hops (.ssh/config).

Update: I found also another link that also contains a Perl script that I assume does exactly what you want. Ref3 ssh tunnel via multiple hops.

Hope this helps.

Seeking for Perl wisdom...on the process of learning...not there...yet!

Replies are listed 'Best First'.
Re^2: How to open nested SSH connection using perl
by Anonymous Monk on Jul 13, 2015 at 06:42 UTC
    Thanks thanos1983 With the help of the link you have given i started the port forwarding and tunneling process in the background and now I am able to do the SSH to host 2 in the script. thanks --girija
      And so, port forwarding is enabled in the gateway server...
      use Net::OpenSSH; my $sshA = Net::OpenSSH->new($serverA, user => $userA, password => $passwordA); my $proxy_command = $sshA->make_remote_command({tunnel => 1}, $serverB +, 22); my $sshB = Net::OpenSSH->new($serverB, user => $userB, password => $passwordB, proxy_command => $proxy_command); $sshB->system($cmd1); $sshB->system($cmd2); ...
        I am getting an error with this code -w option is not known option then we try to do

        my $sshB = Net::OpenSSH->new($serverB, user => $userB, password => $passwordB, proxy_command => $proxy_command);