steelcarn99 has asked for the wisdom of the Perl Monks concerning the following question:

I’ve been attempting to use the Net::SSH module but can’t seem to get everything working. My perl program seems to be able to make the ssh connection to the machine I want, but I can’t run any commands to it. I’ve already set up a passphrase for an RSA key, which is being prompted for (I’ve tested this authentication on Putty and it works).

OpenSSH version 5.1p1
Perl v5.10.0 built for cygwin-thread-multi-64int
Module Net::OpenSSH 0.36
Windows XP Professional

The following is my code:
#filename: ingest.pl # start of Net::OpenSSH use Net::OpenSSH; my $host = '************'; my $port = '22'; my $user = 'root'; my $pass = '***********'; my $ssh = Net::OpenSSH->new($host); $ssh->error and die "couldn't establish connection: " . $ssh->error; $ssh->system("ls") or die "remote command failed: " . $ssh->error; my @ls = $ssh->capture("ls"); $ssh->error and die "remote ls command failed: " . $ssh->error;
This returns the following lines as the errors, for which I can’t seem to find any good support on. I appreciate your time and any suggestions you might have. Thankyou.

mm_receive_fd: no message header
muxserver_accept_control: failed to receive fd 0 from slave
ssh_msg_recv: read: header
muxclient: msg_recv
remote command failed: child exited with code 255 at ingest.pl line 209

Replies are listed 'Best First'.
Re: Module Net::OpenSSH error child exited with code 255
by salva (Canon) on Jul 31, 2009 at 18:05 UTC
    Net::OpenSSH does not work on Windows, not even when using the Cygwin perl!

    Net::OpenSSH uses a feature available in recent OpenSSH ssh clients that allows to establish the SSH connection to the remote host from one process and then, reuse it from other processes.

    Unfortunately, that feature does not work under Windows because these OSs lack support for passing open file handles between processes through local sockets that's the way OpenSSH internally connects SSH channels to the I/O streams of the slave processes.

    AFAIK, nobody has found a way to overcome this limitation yet.

    Try Net::SSH2, Net::SSH::Perl, Net::SSH::Expect (that works under Cygwin but not under other perls for Windows) or Net::SSH.

Re: Module Net::OpenSSH error child exited with code 255
by Khen1950fx (Canon) on Aug 01, 2009 at 00:21 UTC
    I can confirm that your script works fine---no errors, but it's on Linux. To follow up on what salva recommended, syphilis wrote a ppm for Net::SSH2 back in November of 2006. You'll find it here
      There has been several releases of Net::SSH2 and the underlaying libssh2 library since Nov 2006. Using a package so old may not be a good idea.