I am using Net::SSH::Perl to execute a command on a remote server as follows:
use Net::SSH::Perl;
my $ssh = Net::SSH::Perl->new($host);
$ssh->login($user, $pass);
my ($stdout, $stderr, $exit) = $ssh->cmd($cmd);
But when I execute the above script, a password prompt comes again. Meaning the password I supplied in $pass is not taken to establish the ssh connection. Why is this? Any idea how I can overcome this? I give below the debug info:
serv1: Reading configuration data /root/.ssh/config serv1: Reading configuration data /etc/ssh_config serv1: Allocated local port 1023. serv1: Connecting to 15.154.59.63, port 22. serv1: Remote protocol version 1.99, remote software version OpenSSH_4.2 serv1: Net::SSH::Perl Version 1.34, protocol version 1.5. serv1: No compat match: OpenSSH_4.2. serv1: Connection established. serv1: Waiting for server public key. serv1: Received server public key (768 bits) and host key (1024 bits). serv1: Host '15.154.59.63' is known and matches the host key. serv1: Encryption type: DES3 serv1: Sent encrypted session key. serv1: Received encryption confirmation. serv1: RSA authentication failed: Can't load public key. serv1: Doing challenge response authentication. Password:
The password prompt should not be coming right, given that I have already supplied the password in $pass variable?
UPDATE(Based on the comments received):
I tried the following:
my $ssh = Net::SSH::Perl->new($host, debug =>1, identity_files => []);
Now, I don't get the message "RSA authentication failed: " but still the password prompt appears. I give below the debug info:
serv1: Allocated local port 1023. serv1: Connecting to 15.154.59.63, port 22. serv1: Remote protocol version 1.99, remote software version OpenSSH_4.2 serv1: Net::SSH::Perl Version 1.34, protocol version 1.5. serv1: No compat match: OpenSSH_4.2. kf-linux-dm3: Connection established. serv1: Waiting for server public key. serv1: Received server public key (768 bits) and host key (1024 bits). serv1: Host '15.154.59.63' is known and matches the host key. serv1: Encryption type: DES3 serv1: Sent encrypted session key. serv1: Received encryption confirmation. serv1: Doing challenge response authentication. Password:
Could someone enlighten me?