$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"; #### localhost.localdomain: Reading configuration data /home/MYUSERNAME/.ssh/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 version 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! #### $ssh->login('MYUSERNAME','FAKEPASS') or die "login fail!\n"; localhost.localdomain: Reading configuration data /home/MYUSERNAME/.ssh/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 version 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 load 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