【发布时间】:2014-06-29 14:43:13
【问题描述】:
我的 perl 模块有问题,我正在尝试使用 CPAN 中的 OpenSSH 模块连接到远程服务器,并且我已正确提供了用户名和密码,但是当我从浏览器运行 CGI 时,我看到以下错误消息“
无法 ssh:无法建立主 SSH 连接:密码错误或 主进程意外退出
需要立即回复并等待, 提前致谢。
这是我的代码
#!/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,但通过浏览器我看到了上述错误,我已正确输入密码和用户名
【问题讨论】:
-
遵循模块文档中的故障排除部分
标签: perl perl-module mod-perl