Perl:Net :: SSH :: Perl,使用密码和pubkey进行身份验证

时间:2016-03-25 08:47:13

标签: perl ssh perlnetssh

我正在使用Net :: SSH :: Perl,它适用于密码或publiey-key身份验证。但如果我试图同时使用它,那就很困难。

但是,如果我尝试使用OpenSSH客户端ssh或sftp,它运行良好。

Heres代码和日志。

my $ssh = Net::SSH::Perl->new("test.int", port => 22, debug => 1);
$ssh->login($usr, $pwd);
debian: Connecting to test.int, port 22.
debian: Remote version string: SSH-2.0-OpenSSH_5.3
debian: Remote protocol version 2.0, remote software version OpenSSH_5.3
debian: Net::SSH::Perl Version 1.38, protocol version 2.0.
debian: No compat match: OpenSSH_5.3
debian: Connection established.
debian: Sent key-exchange init (KEXINIT), wait response.
debian: Algorithms, c->s: 3des-cbc hmac-sha1 none
debian: Algorithms, s->c: 3des-cbc hmac-sha1 none
debian: Entering Diffie-Hellman Group 1 key exchange.
debian: Sent DH public key, waiting for reply.
debian: Received host key, type 'ssh-dss'.
debian: Host 'test.int' is known and matches the host key.
debian: Computing shared secret key.
debian: Verifying server signature.
debian: Waiting for NEWKEYS message.
debian: Send NEWKEYS.
debian: Enabling encryption/MAC/compression.
debian: Sending request for user-authentication service.
debian: Service accepted: ssh-userauth.
debian: Trying empty user-authentication request.
debian: Authentication methods that can continue: publickey,password.
debian: Next method to try is publickey.
debian: Next method to try is password.
debian: Trying password authentication.
debian: Authentication methods that can continue: publickey.
debian: Next method to try is publickey.
Permission denied at test.pl line 38.

这是控制台客户端sftp的调试日志,它工作正常。

...
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/test/.ssh/id_rsa
debug1: Server accepts key: pkalg ssh-rsa blen 279
Authenticated with partial success.
debug1: Authentications that can continue: password
debug1: Next authentication method: password
test@test.int password:
debug1: Authentication succeeded (password).
Authenticated to test.int ([192.168.1.10]:22). 
...

欢迎任何帮助或建议,谢谢!

0 个答案:

没有答案