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

Hi, I am using activeperl 5.10.1. Here is my code:
use strict; use warnings; use Net::SSH::W32Perl; 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, protocol => 2); $ssh->login($user, $pass); my @sV= $ssh->cmd($cmd); .... .... .... $ssh->close();
The Script is stopping at the login method... leaving me at
... ... Computing shared secret key. Verifying server signature. Waiting for NEWKEYS message. Send NEWKEYS. Enabling encryption/MAC/compression. Sending request for user-authentication service. Service accepted: ssh-userauth. Trying empty user-authentication request. Trying password authentication. Authentication methods that can continue: publickey,gssapi-with-mic,pa + +ssword. Next method to try is publickey. Next method to try is password. Permission denied at win32.pl line 11
I am able to connect to target system through putty ssh interface. but with script im stopped at this login... Any comments why this is happening... I am using valid user credentials. Appreciate your help. Thanks, Thiru

Replies are listed 'Best First'.
Re: User Authentication is not working in Net::SSH::W32Perl
by jethro (Monsignor) on Mar 10, 2010 at 17:54 UTC
    Does your password contain spaces or special characters that might have been changed by the command shell? Try printing $pass and check if it is what you expect.
      Thanks Jethro...
Re: User Authentication is not working in Net::SSH::W32Perl
by Khen1950fx (Canon) on Mar 10, 2010 at 22:29 UTC
    Your script has some errors.

    First, my @sV = $ssh->cmd($cmd) doesn't work. Second, $ssh->close() doesn't work either. The best way is still what the module's documentation says:

    #!/usr/bin/perl use strict; use warnings; use Net::SSH::W32Perl; my $host = 'host'; my $user = 'user'; my $pass = 'password'; my $cmd = 'ls'; 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;