首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法使用Net::SSH:Perl登录

无法使用Net::SSH:Perl登录
EN

Stack Overflow用户
提问于 2015-08-07 23:05:57
回答 1查看 766关注 0票数 0

我刚刚开始使用Net::SSH::Perl,我似乎有点奇怪。如果我将交互式标志设置为1并输入我的密码,我将通过ssh远程登录到机器上,但如果我将交互式标志关闭或设置为0,则登录失败。我确认我能够使用Net::SSH::Perl登录到我的本地机器,所以对于这台特定的远程计算机来说,它肯定是我做错了的事情,底层操作系统是SuSE。我还确认我能够从终端窗口向远程机器发送ssh。

代码语言:javascript
复制
use Net::SSH::Perl;
my $cmd = 'uptime';
my $ssh = Net::SSH::Perl->new($host, interactive=> 0, debug => 1);
$ssh->login($user, $pass);
my($stdout, $stderr, $exit) = $ssh->cmd($cmd);
print $stdout;

下面是当交互式标志设置为0时从调试中输出的日志。

代码语言:javascript
复制
localhost.localdomain: Reading configuration data /home/user/.ssh/config
localhost.localdomain: Reading configuration data /etc/ssh_config
localhost.localdomain: Connecting to 1.1.1.1, port 22.
localhost.localdomain: Remote version string: SSH-2.0-OpenSSH_5.1

localhost.localdomain: Remote protocol version 2.0, remote software version OpenSSH_5.1
localhost.localdomain: Net::SSH::Perl Version 1.38, protocol version 2.0.
localhost.localdomain: No compat match: OpenSSH_5.1
.
localhost.localdomain: Connection established.
localhost.localdomain: Sent key-exchange init (KEXINIT), wait response.
localhost.localdomain: Algorithms, c->s: 3des-cbc hmac-sha1 none
localhost.localdomain: Algorithms, s->c: 3des-cbc hmac-sha1 none
localhost.localdomain: Entering Diffie-Hellman Group 1 key exchange.
localhost.localdomain: Sent DH public key, waiting for reply.
localhost.localdomain: Received host key, type 'ssh-dss'.
localhost.localdomain: Host '1.1.1.1' is known and matches the host key.
localhost.localdomain: Computing shared secret key.
localhost.localdomain: Verifying server signature.
localhost.localdomain: Waiting for NEWKEYS message.
localhost.localdomain: Send NEWKEYS.
localhost.localdomain: Enabling encryption/MAC/compression.
localhost.localdomain: Sending request for user-authentication service.
localhost.localdomain: Service accepted: ssh-userauth.
localhost.localdomain: Trying empty user-authentication request.
localhost.localdomain: Authentication methods that can continue: publickey,keyboard-interactive.
localhost.localdomain: Next method to try is publickey.
localhost.localdomain: Publickey: testing agent key 'user@localhost.localdomain'
localhost.localdomain: Authentication methods that can continue: publickey,keyboard-interactive.
localhost.localdomain: Next method to try is publickey.
localhost.localdomain: Publickey: testing agent key 'user'
localhost.localdomain: Authentication methods that can continue: publickey,keyboard-interactive.
localhost.localdomain: Next method to try is publickey.
Permission denied at /home/user/workspace/perl-random/avamar_ssh.pl line 4.

我猜我做错了什么,所以如果有人能指出正确的方向,那就太棒了。

谢谢。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-08-08 00:22:06

本部分:

代码语言:javascript
复制
localhost.localdomain: Authentication methods that can continue: publickey,keyboard-interactive.

意味着服务器允许使用两种方法进行身份验证:

  • publickey -公钥身份验证
    • 你在评论中提到,这对你来说不是一种选择。

  • keyboard-interactive -输入密码
    • 这只在交互模式下起作用,这一点也就不足为奇了。

所以,你想做的事是不可能的。

好消息是,这听起来像X问题。如果你能给我们更多关于你真正问题的细节,我们也许能提出一个更好的方法。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31887854

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档