Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^2: Remote shell via ssh

by BernieC (Pilgrim)
on Aug 15, 2018 at 11:36 UTC ( [id://1220364]=note: print w/replies, xml ) Need Help??


in reply to Re: Remote shell via ssh
in thread Remote shell via ssh

In the thread Net:SSH2 channels after a fair bit of going-around I discovered that the reason that I couldn't get a channel was twofold. First, auth_ok lies and second, the auth_password just didn't work. Another poster in the thread said he had similar problems. I didn't pursue it any further: once I switched to publickey all the problems went away {and I turned to other troubles I had in my code :o)}. I believe this was a windows problem -- several folk confirmed that it worked OK on unix. If I get a chance I'll try it again and post more info if I get it.

Replies are listed 'Best First'.
Re^3: Remote shell via ssh
by pryrt (Abbot) on Aug 15, 2018 at 14:08 UTC

    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

Re^3: Remote shell via ssh
by hippo (Bishop) on Aug 15, 2018 at 12:42 UTC
    I believe this was a windows problem -- several folk confirmed that it worked OK on unix.

    I see. In that case I will be not be in a position to help you solve it. :-)

    However, if you can verify that it is a problem with the module (even if only on MSWin32), it would be good to raise that as an issue so that it can be fixed by the maintainers.

Re^3: Remote shell via ssh
by VinsWorldcom (Prior) on Aug 15, 2018 at 14:09 UTC

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (4)
As of 2024-04-25 20:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found