Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Perl Net::SSH2 unable to connect

by VinsWorldcom (Vicar)
on Feb 26, 2013 at 21:07 UTC ( #1020759=note: print w/ replies, xml ) Need Help??


in reply to Perl Net::SSH2 unable to connect

The line:

if ($ssh2->auth_keyboard($user,$pass)) {

doesn't work for me either. I get the same error with correct credentials.

Try using your commented out auth_password() instead of auth_keyboard() and it worked for me:

VinsWorldcom@C:\Users\VinsWorldcom\tmp> grep auth_ test.pl #if ($ssh2->auth_password($user,$pass)) { if ($ssh2->auth_keyboard($user,$pass)) { VinsWorldcom@C:\Users\VinsWorldcom\tmp> perl test.pl ssh auth failed. Net::SSH2::DESTROY object 0x2398d78 VinsWorldcom@C:\Users\VinsWorldcom\tmp> grep auth_ test.pl if ($ssh2->auth_password($user,$pass)) { #if ($ssh2->auth_keyboard($user,$pass)) { VinsWorldcom@C:\Users\VinsWorldcom\tmp> test.pl Executing command... ==> Running ls Undefined subroutine &main::is_sshalive called at C:\Users\vincen_m\tm +p\test.pl line 18. Net::SSH2::DESTROY object 0x2398d78

Note: The error in the second output has to do with is_sshalive() not being a valid sub - not sure where you've defined that.


Comment on Re: Perl Net::SSH2 unable to connect
Select or Download Code
Re^2: Perl Net::SSH2 unable to connect
by kabachaa (Novice) on Feb 26, 2013 at 21:44 UTC

    Oh looks like that worked thanks both McA and VinsWorldcom

    Another question I had was there is a method

     $ssh2->error  

    I guess it returns an error code what do these code mean. I get an error code like (0, 13, 7 etc)

    Last question I have is that if I am connected to $ssh2 until I say $ssh2->disconnect i would remain connected and I can do continue running my script. Thanks !

Re^2: Perl Net::SSH2 unable to connect
by VinsWorldcom (Vicar) on Feb 27, 2013 at 13:59 UTC

    From the perldoc:

    VinsWorldcom@C:\Users\VinsWorldcom> perldoc Net::SSH2 [...] error Returns the last error code; returns false if no error. In list cont +ext, returns (code, error name, error string). [...]

    I would try calling the error() accessor like such (untested):

    use Net::SSH2; [...] my $ssh2 = Net::SSH2->new(); [...] my ($code, $name, $string) = $ssh2->error; print "Error ($code): $name - $string\n";

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1020759]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (7)
As of 2015-07-04 20:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (60 votes), past polls