我正在使用 Net::SSH::Perl,它适用于密码或公钥身份验证。但是,如果我尝试同时使用这两种方法,它就会很困难。
但是,如果我使用 OpenSSH 客户端 ssh 或 sftp 尝试它,它运行良好。
继承人代码和日志。
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).
...
欢迎任何帮助或建议,谢谢!