perl - 无法 ssh :unable to establish master SSH connection: bad password or master process exited unexpectedly

标签 perl perl-module mod-perl

我的 perl 模块有问题,我正在尝试使用 CPAN 中的 OpenSSH 模块连接到远程服务器,并且我已经正确给出了用户名和密码,但是当我从浏览器运行我的 CGI 时,我看到以下错误消息“

can't ssh:unable to establish master SSH connection: bad password or master process exited unexpectedly

需要立即回复并等待, 提前致谢。

这是我的代码

#!/usr/bin/perl -w
use CGI;
use Data::Dumper;
use strict;
use CGI::Carp qw(fatalsToBrowser);
use Net::OpenSSH;


my $query = CGI->new();
#my $mach_name=$query->param('mach_name');
my $mach_name= '****.cce.***.com';
my $user='root';
my $passwd='*******';
my $ssh = Net::OpenSSH->new("$mach_name",user => "$user" , passwd => "$passwd
", master_opts => [-o => "strictHostKeyChecking=no"]);
$ssh->error and die "can't ssh:" . $ssh->error;
my $mem_info =$ssh->capture("ioscan -m lun");
print "$mem_info";
print "Content-type: text/html\n\n";
print "<html><head><title>test page</title></head>\n";
print "<body><p>Dicovering Machine Please wait....</p>\n";
print "<p>$mach_name</p>";
print "<p><b>Swap Memory :$mem_info </b> </p>";
print "</body></html>";

如果我通过命令行运行相同的程序,它会获取o/p,但通过浏览器我会看到上述错误,我已经正确给出了密码和用户名

最佳答案

当我将超时从 10 秒增加到 15 秒时,我的问题得到了解决,因为设备使用的是较旧的 SSH 守护程序版本,但我的进行客户端连接的 Linux 服务器已升级,当然它首先探测较新的密码。

my $ssh = Net::OpenSSH->new(
$host,
port                => $port,
user                => $user,
password            => $pass,
timeout             => 15,       # <= this was 10 and now is 15
kill_ssh_on_timeout => 1,
strict_mode         => 0,
master_opts         => [-o => "StrictHostKeyChecking=no", '-vvv'], #<= -vvv helped much
ctl_dir             =>'/tmp/libnet-openssh-perl',

关于perl - 无法 ssh :unable to establish master SSH connection: bad password or master process exited unexpectedly,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23605605/

相关文章:

perl - 在 Perl 中重载 '='

perl - 如何制作 Mojolicious::Lite 静态文件下载器?

Perl 服务器端跨域检测

perl - 使用 Perl 创建包

perl - 在 conda 安装的程序中无法在 @INC 中找到 File/Slurp.pm

perl - 如何将 Perl 代码从 mod_perl 移植到 FastCGI?

apache - mod_perl 死了吗?

perl - 如何检查 IP 号码是否与 Perl 在同一子网中?

perl - 如何使用对安装在非标准位置的 Perl 模块的依赖?

perl - 如何在perl中上传多个文件?