2010-08-26 27 views
7

Tôi đang cố gắng sử dụng Net::SSH::Perl để kết nối sử dụng khóa công khai với mã này:làm thế nào để sử dụng Net :: SSH :: Perl với khóa công khai?

my $ssh = Net::SSH::Perl->new($host, debug=>1) || die ...... 

tôi đặt chìa khóa trong /root/.ssh/id_rsa và /root/.ssh/identity

Nó có vẻ như nó không cố gắng sử dụng khóa công khai và thay vào đó cố gắng để yêu cầu một mật khẩu:

tôi nhận được kết quả này:

 

localhost: Sent key-exchange init (KEXINIT), wait response. 
localhost: Algorithms, c->s: 3des-cbc hmac-sha1 none 
localhost: Algorithms, s->c: 3des-cbc hmac-sha1 none 
localhost: Entering Diffie-Hellman Group 1 key exchange. 
localhost: Sent DH public key, waiting for reply. 
localhost: Received host key, type 'ssh-dss'. 
localhost: Host '10.212.1.201' is known and matches the host key. 
localhost: Computing shared secret key. 
localhost: Verifying server signature. 
localhost: Waiting for NEWKEYS message. 
localhost: Send NEWKEYS. 
localhost: Enabling encryption/MAC/compression. 
localhost: Sending request for user-authentication service. 
localhost: Service accepted: ssh-userauth. 
localhost: Trying empty user-authentication request. 
localhost: Authentication methods that can continue: publickey,gssapi-with-mic,password. 
localhost: Next method to try is publickey. 
localhost: Next method to try is password. 
localhost: Trying password authentication. 
localhost: Will not query passphrase in batch mode. 
localhost: Authentication methods that can continue: publickey,gssapi-with-mic,password. 
localhost: Next method to try is publickey. 
localhost: Next method to try is password. 
localhost: Trying password authentication. 
localhost: Will not query passphrase in batch mode. 
localhost: Authentication methods that can continue: publickey,gssapi-with-mic,password. 
localhost: Next method to try is publickey. 
localhost: Next method to try is password. 
localhost: Trying password authentication. 
localhost: Will not query passphrase in batch mode. 
localhost: Authentication methods that can continue: publickey,gssapi-with-mic,password. 
localhost: Next method to try is publickey. 
localhost: Next method to try is password. 

Trả lời

10

tìm thấy nó: ha ve để chỉ định vị trí tệp khóa theo cách thủ công:

@KEYFILE = ("/root/.ssh/id_rsa"); 
$ssh = Net::SSH::Perl->new($host, debug=>1, identity_files=>\@KEYFILE) 
Các vấn đề liên quan