How to get Net::SSH::W32Perl

Posted by KalTorak on 2008-07-25 16:11
Forums: PPM | OS: Windows

Does the reputed Net::SSH::W32Perl rev 0.06 actually exist?
People claim they have it, but is gone, and installing PPMs directly from there seemed to be involved...

I've got ActiveState perl 5.8.8 build 822 installed.
I got Net::SSH::W32Perl (rev 0.05) installed from the UWinnipeg PPM repository, and I'm trying to do a simple "Run a command on a Unix box" script. Most(?) importantly, I uninstalled Net::SFTP, Net::SSH::Perl, and Net::SSH::W32Perl, and installed only Net::SSH::W32Perl (and let it take care of its own dependencies) - that seems to have been some people's answer.

I hit the getpwuid problem, I set HOME=something, and got around it.
I couldn't authenticate against the ssh daemon on the other end, I got a public/private key pair set up and working - I can login.

But as soon as I try a cmd(), I hang. Lots of people seem to have a similar issue, and I can't seem to find a fix.

My script (with a couple things anonymized):

use Net::SSH::W32Perl;

$host = "myserver";
$user = "myuserid";

my $ssh = Net::SSH::W32Perl->new($host,
                                 debug => 1,
                                 interactive => 0,
                                 use_pty => 0,
                                 identity_files => ["id_rsa"]);

$cmd = '/usr/bin/date > ~/date';

#my($out, $err, $exit) = $ssh->cmd($cmd);
$ssh->cmd($cmd, "\n");

print "STDOUT: $out";
print "\n\n";
print "STDERR: $err";
print "\n\n";
print "ExitCode: $exit";
print "\n\n";

The results:

client: Requesting service shell on channel 0.
client: channel 1: new [client-session]
client: Requesting channel_open for channel 1.
client: Entering interactive session.
client: Sending command: /usr/bin/date > ~/date
client: Requesting service exec on channel 1.
client: channel 1: send eof
client: channel 1: open confirm rwindow 262143 rmax 16384
(and here we hang indefinitely)

I've redirected stdout in the command I'm sending, and I've left it non-redirected - no difference.
I tried adding and removing the "\n" argument to the cmd() arg list - removing it drops the "client: channel 1: send eof" debug info, but that's all.
I made sure to install only the W32Perl module, so it could manage its own dependencies - no difference.
I know the command works - there's a ~/date file that's getting created on the server side... it's just that my client script hangs.

Am I missing something?
Is there any solution which does NOT involve installing the PPMs from a Soulcage repository that doesn't exist?


lgastevens | Sun, 2008-10-05 11:34

Stumbled on pretty much all the same problems with Net::SSH::W32Perl, and after reading this post and others decided to give up on it.
I concentrated to Net::SSH2 instead and have now got it working on Win32. I installed it from Uwinnipeg PPM repository on Perl build 822.
There are a couple of things which don't seem to work for me (polling and auth_keyboard) but overall I got it to do what I wanted (issuing commands to Nortel ERS switches via the shell)