in reply to Re^3: Unable to do SCP on multiple machines using Perl's Net::SCP::Expect module
in thread Unable to do SCP on multiple machines using Perl's Net::SCP::Expect module

Thanks! I tried using Net::OpenSSH with key_path option.
my $key_path = "/home/tom/.ssh/id_file"; my $ssh = Net::OpenSSH->new( $host, key_path => $key_path, ); $ssh->scp_put("$war_full_path", "$ENV{HOME}") or die "SCP failed: " . +$ssh->error;
Now it fails with the message:
Permission denied (publickey).
SCP failed: unable to establish master SSH connection: master process exited unexpectedly at /home/tom/deploy.pl line 64

Line 64 is the above line where i am using scp_put
  • Comment on Re^4: Unable to do SCP on multiple machines using Perl's Net::SCP::Expect module
  • Download Code

Replies are listed 'Best First'.
Re^5: Unable to do SCP on multiple machines using Perl's Net::SCP::Expect module
by salva (Canon) on May 05, 2014 at 10:32 UTC
    Are you able to log from the command line?
    ssh -vv -i "/home/tom/.ssh/id_file" hostname

      I'm really sorry for the blunder salva. I was not passing the user name while creating the connection. Now SSH is working fine on both the machines.

      After this worked, i realized the mistake that I was committing while using the earlier module (Net::SCP::Expect). Now the script is working with that module too. To simplify the explanation, in the first SCP, i needed to run the SCP as user A while in second SCP, which was on a different server, I needed a different user. However, in my script, I was using the same user A for performing SCP on both the machines and that’s why it wasn’t working.

      Your pointer helped me in realizing the blunder I was committing. Thanks a lot! :)