Question

use strict;
use warnings;
use Net::OpenSSH;

$Net::OpenSSH::debug |= 16;

my $ssh = Net::OpenSSH->new(host=>'xx.xx.xx.xx',
                            user => 'xxxx',
                            password => 'xxxx'
);

$ssh->error and die "SSH connection failed: " . $ssh->error;
my $command = "ls";
my @out = $ssh->capture($command);
print @out;

the above prog gives following error

SSH connection failed: unable to determine home directory for uid 0 at ./ssh.pl
line 12.

I am using avtivestate perl (v5.12.3)

although i give another user instead of root it gives same error.
I have centos 6.4 on host.
can anyone help me?

Was it helpful?

Solution

From the documentation for Net::OpenSSH:

On the other hand, Net::OpenSSH does not work on Windows, not even under Cygwin.

For an alternative solution: How do we configure SSH using Perl in Windows?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top