Hi Salva, thanks for your reply. I've read through the documentation for OpenSSH and it seems like a much better method than my current attempts. I'm getting really confused though with the examples in the documentation, and my own attempts aren't going well. Would you be able to help further? My current code sample is below.
#!/usr/bin/perl -wT
use Net::OpenSSH;
$ENV{PATH} = "/bin";
my $ssh = Net::OpenSSH->new("<IP>", user => "<username>", password =>
+"<password>");
$ssh->error and die "Can't ssh to host: " . $ssh->error;
$ssh->system('whoami')or die "whoami failed: " .$ssh->error;
I should say, I have tried this without the password bit (as I use private key authentication) as well, and I have tried using syntax such as my $ssh = Net::OpenSSH->new("<user>\@<Host IP>");.
I get the following error:
Can't exec "ssh": No such file or directory at /usr/share/perl5/Net/Op
+enSSH.pm line 731.
Can't ssh to host: unable to establish master SSH connection: master p
+rocess exited unexpectedly
Do you have any further advice?
Thanks very much again! Really appreciate your help.
|