首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >拒绝在ssh.pl行17 -$ssh->登录($user,$password)的权限;

拒绝在ssh.pl行17 -$ssh->登录($user,$password)的权限;
EN

Stack Overflow用户
提问于 2014-05-02 14:49:25
回答 2查看 1.7K关注 0票数 3

我试图将ssh放到机器中,并使用perl脚本运行一个名为mounted的命令。

我不断地发现错误:

代码语言:javascript
复制
Permission denied at ssh.pl line 17

第17行:

代码语言:javascript
复制
$ssh->login($user, $password);

有人能帮我理解原因吗?

这是我的完整剧本:

代码语言:javascript
复制
#!/usr/local/bin/perl -w

use strict;
use warnings;
require Net::SSH::Perl;

#declare our login vars...

my $user = "root";
my $password = "";
my $server = "beccles";

#Setup our SSH Connection...
my $ssh = Net::SSH::Perl->new($server,port=>22,protocol=>2, debug => 1);

#Initiate out conneciton to the server...
$ssh->login($user, $password);

# Declare our variable for the request...
my $mounts;
my $name;

# Run our SSH Command and retrieve the output...
($mounts) = $ssh->cmd(`mounted`);
($name) = $ssh->cmd("uname -n");

# Print Output
chomp $name;
#print "\n$mounts\n";

exit 0;

下面是调试ssh连接后获得的输出:

代码语言:javascript
复制
calver: Remote protocol version 2.0, remote software version OpenSSH_5.3
calver: Net::SSH::Perl Version 1.37, protocol version 2.0.
calver: No compat match: OpenSSH_5.3
calver: Connection established.
calver: Sent key-exchange init (KEXINIT), wait response.
calver: Algorithms, c->s: 3des-cbc hmac-sha1 none
calver: Algorithms, s->c: 3des-cbc hmac-sha1 none
calver: Entering Diffie-Hellman Group 1 key exchange.
calver: Sent DH public key, waiting for reply.
calver: Received host key, type 'ssh-dss'.
calver: Host 'beccles' is known and matches the host key.
calver: Computing shared secret key.
calver: Verifying server signature.
calver: Waiting for NEWKEYS message.
calver: Send NEWKEYS.
calver: Enabling encryption/MAC/compression.
calver: Sending request for user-authentication service.
calver: Service accepted: ssh-userauth.
calver: Trying empty user-authentication request.
calver: Authentication methods that can continue: publickey,gssapi-keyex,gssapi-   
with-mic,keyboard-interactive.
calver: Next method to try is publickey.
calver: Publickey: testing agent key '/u/blh/.ssh/blh_git'
calver: Authentication methods that can continue: publickey,gssapi-keyex,gssapi-   
with-mic,keyboard-interactive.
calver: Next method to try is publickey.
Permission denied at ssh.pl line 17

感谢您的帮助,如果需要更多的信息,请咨询我。

谢谢:)

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2014-05-04 01:04:05

因此,要从AKHolland的评论和Arthur Ulfeldthis own question的回答中得到一个正式的答案:

使用键并手动定义密钥文件位置:

代码语言:javascript
复制
@KEYFILE = ("/root/.ssh/id_rsa");
$ssh = Net::SSH::Perl->new($host, debug=>1, identity_files=>\@KEYFILE)
票数 1
EN

Stack Overflow用户

发布于 2016-05-09 21:44:01

这是一个旧线程,但它是在我搜索与Net::SSH::Perl相关的其他项时出现的。

这假设代码中显示的密码不是空字符串,实际上是经过修改但有效的密码。

我遇到了这样的问题,问题是我假设在以交互方式登录到远程主机时使用密码身份验证。实际上,我使用的是keyboard-interactive身份验证,password身份验证在sshd服务器上被禁用。

我将PasswordAuthentication yes添加到我的/etc/ssh/sshd_config中,重新启动sshd进程,所有这些都与Net::SSH::Perl很好。

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

https://stackoverflow.com/questions/23430966

复制
相关文章

相似问题

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