The documentation makes it sound like the following code would work (using RSA Authentication).

$ssh->login([ $user [, $password ] ]) Sets the username and password to be used when authenticating with the sshd daemon. The username $user is required for all authentication protocols (to identify yourself to the remote server), but if you don't supply it the username of the user executing the program is used. The password $password is needed only for password authentication (it's not used for passphrases on encrypted RSA/DSA identity files, though perhaps it should be). And if you're running in an interactive session and you've not provided a password, you'll be prompted for one.
use Net::SSH::Perl; $ssh = Net::SSH::Perl->new('localhost', debug=>1); $ssh->login() or die "login fail!\n"; ($i,$j,$k) = $ssh->cmd('ls | wc -l'); print "$i\n";

It doesn't.

localhost.localdomain: Reading configuration data /home/MYUSERNAME/.ss +h/config localhost.localdomain: Reading configuration data /etc/ssh_config localhost.localdomain: Connecting to localhost, port 22. localhost.localdomain: Remote protocol version 1.5, remote software ve +rsion 1.2.32 localhost.localdomain: Net::SSH::Perl Version 1.23, protocol version 1 +.5. localhost.localdomain: No compat match: 1.2.32. localhost.localdomain: Connection established. login fail!

However, if I explicitly give MYUSERNAME and a FAKE password...

$ssh->login('MYUSERNAME','FAKEPASS') or die "login fail!\n"; localhost.localdomain: Reading configuration data /home/MYUSERNAME/.ss +h/config localhost.localdomain: Reading configuration data /etc/ssh_config localhost.localdomain: Connecting to localhost, port 22. localhost.localdomain: Remote protocol version 1.5, remote software ve +rsion 1.2.32 localhost.localdomain: Net::SSH::Perl Version 1.23, protocol version 1 +.5. localhost.localdomain: No compat match: 1.2.32. localhost.localdomain: Connection established. localhost.localdomain: Waiting for server public key. localhost.localdomain: Received server public key (768 bits) and host +key (1024 bits). localhost.localdomain: Host 'localhost' is known and matches the host +key. localhost.localdomain: Encryption type: DES3 localhost.localdomain: Sent encrypted session key. localhost.localdomain: Received encryption confirmation. localhost.localdomain: Trying rhosts authentication. localhost.localdomain: Trying rhosts or /etc/hosts.equiv with RSA host + authentication. localhost.localdomain: Rhosts with RSA authentication failed: Can't lo +ad private host key. localhost.localdomain: Trying RSA authentication with key 'MYUSERNAME@ +localhost.localdomain' localhost.localdomain: Received RSA challenge from server. localhost.localdomain: Sending response to host key RSA challenge. localhost.localdomain: RSA authentication accepted by server. localhost.localdomain: Sending command: ls | wc -l localhost.localdomain: Entering interactive session. 127

Anybody else run into this sorta thing?


In reply to Net::SSH::Perl gotcha! by zengargoyle

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.