本文介绍了如何将 Net::SSH::Perl 与公钥一起使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用 Net::SSH::Perl 通过此代码使用公钥进行连接:
my $ssh = Net::SSH::Perl->new($host, debug=>1) ||死 ......我把密钥放在/root/.ssh/id_rsa 和/root/.ssh/identity
它似乎不是试图使用公钥,而是试图要求输入密码:
我得到这个输出:
本地主机:发送密钥交换初始化(KEXINIT),等待响应.本地主机:算法,c->s:3des-cbc hmac-sha1 无本地主机:算法,s->c:3des-cbc hmac-sha1 无本地主机:进入 Diffie-Hellman Group 1 密钥交换.localhost:发送DH公钥,等待回复.本地主机:收到主机密钥,输入ssh-dss".本地主机:主机 '10.212.1.201' 已知并匹配主机密钥.localhost:计算共享密钥.本地主机:验证服务器签名.本地主机:等待 NEWKEYS 消息.本地主机:发送新密钥.本地主机:启用加密/MAC/压缩.localhost:发送用户认证服务请求.本地主机:接受服务:ssh-userauth.本地主机:尝试空的用户身份验证请求.localhost:可以继续的认证方法:publickey、gssapi-with-mic、password.本地主机:下一个尝试的方法是公钥.本地主机:下一个尝试的方法是密码.本地主机:尝试密码认证.localhost:不会在批处理模式下查询密码.localhost:可以继续的认证方法:publickey、gssapi-with-mic、password.本地主机:下一个尝试的方法是公钥.localhost:下一个尝试的方法是密码.本地主机:尝试密码认证.localhost:不会在批处理模式下查询密码.localhost:可以继续的认证方法:publickey、gssapi-with-mic、password.本地主机:下一个尝试的方法是公钥.localhost:下一个尝试的方法是密码.本地主机:尝试密码认证.localhost:不会在批处理模式下查询密码.localhost:可以继续的认证方法:publickey、gssapi-with-mic、password.本地主机:下一个尝试的方法是公钥.localhost:下一个尝试的方法是密码. 解决方案发现:必须手动指定密钥文件位置:
@KEYFILE = ("/root/.ssh/id_rsa");$ssh = Net::SSH::Perl->new($host, debug=>1, identity_files=>\@KEYFILE)I'm trying to use Net::SSH::Perl to connect using public keys with this code:
my $ssh = Net::SSH::Perl->new($host, debug=>1) || die ......I put the key in /root/.ssh/id_rsa and /root/.ssh/identity
It seems that it's not trying to use the public key and instead trying to ask for a password:
I get this output:
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.解决方案
found it: have to specify the key file location manually:
@KEYFILE = ("/root/.ssh/id_rsa"); $ssh = Net::SSH::Perl->new($host, debug=>1, identity_files=>\@KEYFILE)
更多推荐
如何将 Net::SSH::Perl 与公钥一起使用?
发布评论