Subject: | Bug: SSH authentication with private key |
Date: | Wed, 18 Feb 2009 11:58:44 +0100 |
To: | bug-Net-SSH-Perl [...] rt.cpan.org |
From: | Sébastien Boelens <sebastien.boelens [...] student.khleuven.be> |
Dear sir,
Currently I'm working on a school project, and I'm using your package
for establishing a SSH connection. We want to use our private key, so
we don't have to supply our password in the Perl file. When using this
identity-file the package just locks up, and doesn't make the
connection.
Script-code:
#! /usr/bin/perl -w
use strict;
use Net::SSH::Perl;
# Use native SSH
#my $ssh = `ssh 503569\@192.168.255.1 uptime`;
#chomp($ssh);
#print "uptime: $ssh\n";
my $ssh = Net::SSH::Perl->new("192.168.255.1",interactive => 1, debug
=> 1, privileged => 0,protocol => '2', identity_files
=>["/root/.ssh/id_rsa"], options => ["User 503569",
"RhostsAuthentication no"]);
$ssh ->login();
my($stdout,$err,$exit)=$ssh->cmd("uptime");
print $stdout."\n";
Debug output:
nwlabo:/scripts# perl PerlSSH.pl
nwlabo: Reading configuration data /root/.ssh/config
nwlabo: Reading configuration data /etc/ssh_config
nwlabo: Connecting to 192.168.255.1, port 22.
nwlabo: Remote protocol version 2.0, remote software version
OpenSSH_4.7p1 Debian-8ubuntu1.2
nwlabo: Net::SSH::Perl Version 1.34, protocol version 2.0.
nwlabo: No compat match: OpenSSH_4.7p1 Debian-8ubuntu1.2.
nwlabo: Connection established.
nwlabo: Sent key-exchange init (KEXINIT), wait response.
nwlabo: Algorithms, c->s: 3des-cbc hmac-sha1 none
nwlabo: Algorithms, s->c: 3des-cbc hmac-sha1 none
nwlabo: Entering Diffie-Hellman Group 1 key exchange.
nwlabo: Sent DH public key, waiting for reply.
nwlabo: Received host key, type 'ssh-dss'.
nwlabo: Host '192.168.255.1' is known and matches the host key.
nwlabo: Computing shared secret key.
nwlabo: Verifying server signature.
nwlabo: Waiting for NEWKEYS message.
nwlabo: Send NEWKEYS.
nwlabo: Enabling encryption/MAC/compression.
nwlabo: Sending request for user-authentication service.
nwlabo: Service accepted: ssh-userauth.
nwlabo: Trying empty user-authentication request.
nwlabo: Authentication methods that can continue: publickey,password.
nwlabo: Next method to try is publickey.
nwlabo: Trying pubkey authentication with key file '/root/.ssh/id_rsa'
strace ./PerlSSH.pl 2>&1:
stat64("/scripts/../../../../lib/Convert/PEM/CBC.pmc", 0xbfac902c) = -1
ENOENT (No such file or directory)
stat64("/scripts/../../../../lib/Convert/PEM/CBC.pm", 0xbfac8f3c) = -1
ENOENT (No such file or directory)
stat64("/scripts/../../../lib/Convert/PEM/CBC.pmc", 0xbfac902c) = -1
ENOENT (No such file or directory)
stat64("/scripts/../../../lib/Convert/PEM/CBC.pm", 0xbfac8f3c) = -1
ENOENT (No such file or directory)
stat64("/scripts/../../lib/Convert/PEM/CBC.pmc", 0xbfac902c) = -1
ENOENT (No such file or directory)
stat64("/scripts/../../lib/Convert/PEM/CBC.pm", 0xbfac8f3c) = -1 ENOENT
(No such file or directory)
stat64("/etc/perl/Convert/PEM/CBC.pmc", 0xbfac902c) = -1 ENOENT (No
such file or directory)
stat64("/etc/perl/Convert/PEM/CBC.pm", 0xbfac8f3c) = -1 ENOENT (No such
file or directory)
stat64("/usr/local/lib/perl/5.8.8/Convert/PEM/CBC.pmc", 0xbfac902c) =
-1 ENOENT (No such file or directory)
stat64("/usr/local/lib/perl/5.8.8/Convert/PEM/CBC.pm", 0xbfac8f3c) = -1
ENOENT (No such file or directory)
stat64("/usr/local/share/perl/5.8.8/Convert/PEM/CBC.pmc", 0xbfac902c) =
-1 ENOENT (No such file or directory)
stat64("/usr/local/share/perl/5.8.8/Convert/PEM/CBC.pm",
{st_mode=S_IFREG|0444, st_size=6469, ...}) = 0
open("/usr/local/share/perl/5.8.8/Convert/PEM/CBC.pm",
O_RDONLY|O_LARGEFILE) = 6
ioctl(6, SNDCTL_TMR_TIMEBASE or TCGETS, 0xbfac8d48) = -1 ENOTTY
(Inappropriate ioctl for device)
_llseek(6, 0, [0], SEEK_CUR) = 0
read(6, "# $Id: CBC.pm 1829 2005-05-25 21"..., 4096) = 4096
_llseek(6, 2648, [2648], SEEK_SET) = 0
_llseek(6, 0, [2648], SEEK_CUR) = 0
close(6) = 0
read(5, "}-----\";\n my $content = encod"..., 4096) = 4096
_llseek(5, 5609, [5609], SEEK_SET) = 0
_llseek(5, 0, [5609], SEEK_CUR) = 0
close(5) = 0
read(4, "_name . \' \' . encode_base64( $_["..., 4096) = 3260
_llseek(4, 5779, [5779], SEEK_SET) = 0
_llseek(4, 0, [5779], SEEK_CUR) = 0
close(4) = 0
open("/root/.ssh/id_rsa", O_RDONLY|O_LARGEFILE) = 4
ioctl(4, SNDCTL_TMR_TIMEBASE or TCGETS, 0xbfac9b38) = -1 ENOTTY
(Inappropriate ioctl for device)
_llseek(4, 0, [0], SEEK_CUR) = 0
fstat64(4, {st_mode=S_IFREG|0600, st_size=1679, ...}) = 0
fcntl64(4, F_SETFD, FD_CLOEXEC) = 0
fstat64(4, {st_mode=S_IFREG|0600, st_size=1679, ...}) = 0
read(4, "-----BEGIN RSA PRIVATE KEY-----\n"..., 4096) = 1679
read(4, "", 4096) = 0
close(4) = 0
brk(0x8c3b000) = 0x8c3b000