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

Hi, I just wrote a simple SSH perl script in windows, to communicate to a system and execute a command. I installed required perl modules Net::SSH::Perl and Math::GMP. Now i am getting this message when i executing the script,

Reading configuration data /.ssh/config
Reading configuration data /etc/ssh_config
Connecting to <host....>, port 22.
Remote protocol version 2.0, remote software version OpenSSH_5.2
Math::BigInt: couldn't load specified math lib(s), fallback to Math::BigInt::FastCalc at C:/Perl/site/lib/Crypt/DH.pm line 6
Net::SSH::Perl Version 1.34, protocol version 2.0.
The getpwuid function is unimplemented at C:/Perl/site/lib/Net/SSH/Perl/SSH2.pm line 39, <GEN0> line 1.

I am using activeperl 5.10.1. Here is my code:
use strict; use warnings; use Net::SSH::Perl; my $host = shift @ARGV; my $user = shift @ARGV; my $pass = shift @ARGV; my $cmd = shift @ARGV; my $ssh = Net::SSH::Perl->new($host, debug => 1); $ssh->login($user, $pass); my @sV= $ssh->cmd($cmd); .... .... .... $ssh->close();
If the getpwuid function is unimplemented, then how can we make SSH communication in perl script in windows. Or is there any other way to do this... Appreciate your help. Thanks, Thiru

Replies are listed 'Best First'.
Re: Net::SSH::Perl script in windows - getpwuid is unimplemented
by syphilis (Archbishop) on Feb 20, 2010 at 01:23 UTC
    Don't know much about Net::SSH::Perl but I've had good success on Windows with Net::SSH2 (available as a ppm from the Uwinnipeg 5.8 and 5.10 repos).
    As the name suggests, it's SSH2 protocol only.

    See the Net::SSH2 test script for an example of usages. In fact, after installing Net::SSH2, it's probably worth grabbing a copy of that script, entering values for $host, $user and $pass at line 16, and then giving it a run to see how it goes. If you have the requisite permissions on $host, it should go pretty well.

    Cheers,
    Rob
Re: Net::SSH::Perl script in windows - getpwuid is unimplemented
by Khen1950fx (Canon) on Feb 20, 2010 at 02:18 UTC
    If you are on Windows, then you'll need to use Net::SSH::W32Perl. Try this instead:
    #!/usr/bin/perl use strict; use warnings; use Net::SSH::W32Perl; my $host = 'localhost'; my $user = 'user'; my $pass = 'password'; my $cmd = 'perldoc -f getpwuid'; my $ssh = Net::SSH::W32Perl->new( $host, debug => 1, protocol => 2 ); $ssh->login($user, $pass); my($stdout, $stderr, $exit) = $ssh->cmd($cmd); print $stdout, "\n"; exit;
      Hi, I tried this W32perl module also. This is also giving the same error. The getpwuid function is unimplemented at C:/Perl/site/lib/Net/SSH/Perl/SSH2.pm line 39, <GEN0> line 1. Thanks, Thiru
        You didn't use Net::SSH::Win32Perl. Look a little closer at the error. The getpwuid function isn't implemented. That means don't try to run getpwuid. Try $ENV{USERNAME} instead.
      Hello I am getting error while running window.
      Math::Pari not locatable. C:\Users\a-mrayappa\Desktop>test.pl CHE3-W01145: Reading configuration data /.ssh/config CHE3-W01145: Reading configuration data /etc/ssh_config CHE3-W01145: Connecting to apm, port 22. CHE3-W01145: Socket created, turning on blocking... CHE3-W01145: Remote version string: SSH-2.0-OpenSSH_4.3 CHE3-W01145: Remote protocol version 2.0, remote software version Open +SSH_4.3 Can't locate loadable object for module Math::Pari in @INC (@INC conta +ins: C:/Pe rl64/site/lib C:/Perl64/lib .) at C:/Perl64/lib/Net/SSH/Perl/Util/SSH2 +MP.pm line 6. Compilation failed in require at C:/Perl64/lib/Net/SSH/Perl/Util/SSH2M +P.pm line 6. BEGIN failed--compilation aborted at C:/Perl64/lib/Net/SSH/Perl/Util/S +SH2MP.pm l ine 6. Compilation failed in require at C:/Perl64/lib/Net/SSH/Perl/Util.pm li +ne 56. BEGIN failed--compilation aborted at C:/Perl64/lib/Net/SSH/Perl/Kex/DH +1.pm line 10. Compilation failed in require at C:/Perl64/lib/Net/SSH/Perl/Kex.pm lin +e 6. BEGIN failed--compilation aborted at C:/Perl64/lib/Net/SSH/Perl/Kex.pm + line 6. Compilation failed in require at C:/Perl64/lib/Net/SSH/Perl/SSH2.pm li +ne 6. BEGIN failed--compilation aborted at C:/Perl64/lib/Net/SSH/Perl/SSH2.p +m line 6.

      Code tags added by GrandFather

        Install Math::Pari?

        Anyway, nowadays you should probably be using Net::SSH2. If you are using Strawberry Perl, it is already included. Check also Net::SSH::Any.

Re: Net::SSH::Perl script in windows - getpwuid is unimplemented
by Anonymous Monk on May 06, 2010 at 22:48 UTC
    "Math::BigInt: couldn't load specified math lib(s), fallback to Math::BigInt::FastCalc at C:/Perl/site/lib/Crypt/DH.pm line 6 Net::SSH::Perl Version 1.34, protocol version 2.0." You need to install these modules by using PPM or download from CPAN