Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

BernieC: I was surprised that a basic feature like password authentication wouldn't work. So I tried on a local machine at $work. It worked with the $ssh2->auth_password() for me. After some more looking, I printed out $ssh2->auth_list(), and that gave a clue, which sounded familiar to something I'd read recently. It turned out to have been clarified by what salva (the module's author) already told you in Re^4: Can't get $ssh2->check_hostkey to work: shell02.theworld.com requires keyboard-interactive authentication, but you were using password authentication, which is not the same thing: so you were using the wrong authentication type. The results of my experiment, to make it more explicit:

#!/usr/bin/env perl use warnings; use strict; use Net::SSH2 ':all'; use Config; my $host = 'REDACTED'; my $username = 'REDACTED'; my $password = 'REDACTED'; print STDERR "__DATA__\n\n__RESULTS__\n"; print STDERR "\$] => $]\n"; print STDERR "$_ => $Config{$_}\n" for qw/archname osname osvers/; print STDERR "\n\nhost at \$work\n"; my $ssh2 = Net::SSH2->new(); my $rv = $ssh2->connect($host) or $ssh2->die_with_error; + print STDERR "\tconnect => $rv\n"; #$rv = $ssh2->check_hostkey(LIBSSH2_HOSTKEY_POLICY_ASK) or $ssh2->die_ +with_error; print STDERR "\tcheck hostkey => $rv\n"; # yes +, I know I should... but not doing this for now; you had trouble, too +... and I trust this local host $rv = $ssh2->auth_list($username) or $ssh2->die_with_error; + print STDERR "\tauth_list => $rv\n"; $rv = $ssh2->auth_password($username, $password) or $ssh2->die_with_er +ror; print STDERR "\tauth_password => $rv\n"; my $chan = $ssh2->channel() or $ssh2->die_with_error; + print STDERR "\tget channel => $rv\n"; $rv = $chan->exec('ls -l') or $ssh2->die_with_error; + print STDERR "\texec ls => $rv\n"; print STDERR "line read: " . $chan->readline(); $rv = $chan->close() or $ssh2->die_with_error; + print STDERR "\tchan close => $rv\n"; $rv = $ssh2->disconnect() or $ssh2->die_with_error; + print STDERR "\tdisconnect => $rv\n"; print STDERR "\n\nshell02.theworld.com:\n"; $ssh2 = Net::SSH2->new(); $ssh2->connect('shell02.theworld.com') or $ssh2->die_with_error; $rv = $ssh2->auth_list() or $ssh2->die_with_error; + print STDERR "\tauth_list => $rv\n"; $rv = $ssh2->auth_password_interact($username) or $ssh2->die_with_erro +r; print STDERR "\tauth_password_interact => $rv\n"; # this wouldn't work on my strawberry perl: "Non-blocking ReadLine + is not supported on this architecture" __DATA__ __RESULTS__ $] => 5.026002 archname => MSWin32-x64-multi-thread osname => MSWin32 osvers => 10.0.16299.371 host at $work connect => 1 auth_list => publickey,gssapi-with-mic,password auth_password => 1 get channel => 1 exec ls => 1 line read: total 948 chan close => 1 disconnect => 1 shell02.theworld.com: auth_list => publickey,keyboard-interactive REDACTED's password? Non-blocking ReadLine is not supported on this ar +chitecture at C:/usr/local/apps/berrybrew/perls/5.26.2_64_PDL/perl/ve +ndor/lib/Net/SSH2.pm line 314.

Notice: my $work host said "publickey,gssapi-with-mic,password" -- ie, it accepts password authentication. But when I checked shell02.theworld.com, it just accepts "publickey,keyboard-interactive". So the valid complaint is "I tried auth_password() even though the host required auth_password_interact(), and it didn't work.".

And, I didn't try very many experiments with auth_password_interact(), but the one I showed above showed that "Non-blocking ReadLine is not supported on this architecture", so it might be a valid complaint to say "My host doesn't accept auth_password(); the host claims to accept auth_password_interact(), but trying that on Strawberry didn't seem to work, and gave the error 'Non-blocking ReadLine is not supported on this architecture'". This would be the response I would give to salva's post in the other thread, to flag salva that there's been a response.

But to claim that "auth_password just didn't work" does not tell the whole, accurate story.

update:: added Re^5: Can't get $ssh2->check_hostkey to work to ask salva about the ReadLine error on strawberry perl

edit 2:: added paragraph breaks to make it more readable


In reply to Re^3: Remote shell via ssh by pryrt
in thread Remote shell via ssh by BernieC

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (2)
As of 2024-04-19 21:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found