Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Net::SSH::Perl gotcha!

by zengargoyle (Deacon)
on May 24, 2002 at 17:44 UTC ( [id://169161]=perlquestion: print w/replies, xml ) Need Help??

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

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?

Replies are listed 'Best First'.
Re: Net::SSH::Perl gotcha!
by premchai21 (Curate) on May 24, 2002 at 19:20 UTC

    "... but if you don't supply it the username of the user executing the program is used..." Is your username the same locally and remotely?

    Though, by my limited understanding of the SSH protocol, that shouldn't make exactly that difference; it should at least go through the next few steps of the connection before failing, if that is the problem. Hmm.

      yes, same user local and remote. it took *hours and hours* to realize that $ssh->login('realme','realpass') wasn't doing the password authentication thing, but that a non-null password was needed for RSA authentication to work.

Re: Net::SSH::Perl gotcha!
by tphyahoo (Vicar) on Dec 18, 2006 at 15:31 UTC

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2024-03-29 12:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found