Chinaunix

标题: 请教关于WIN下 Net::SSH::Perl 的问题 [打印本页]

作者: cc964894    时间: 2007-04-26 14:35
标题: 请教关于WIN下 Net::SSH::Perl 的问题
在测试该模块的时候出现了一个问题
代码:(模块来自soulcage)
___
use Net::SSH:erl;
my $host= '172.16.1.2';
my $username= 'root';
my $password= 'cc';
my $cmd= '/sbin/ifconfig';
my $ssh = Net::SSH:erl->new($host,protocol =>2,port =>22,debug=>1,options => [ "BatchMode yes", "RSAAuthentication no","asswordAuthentication yes" ]);
$ssh->login($username,$password);
my($stdout, $stderr, $exit) = $ssh->cmd($cmd);
print "$stdout, $stderr, $exit\n";

——————错误提示
: Reading configuration data /.ssh/config
: Reading configuration data /etc/ssh_config
: Connecting to 172.16.1.2, port 22.
: Remote protocol version 1.99, remote software version OpenSSH_4.6
: Net::SSH:erl Version 1.23_01, protocol version 2.0.
: No compat match: OpenSSH_4.6.
Your vendor has not defined Fcntl macro F_SETFL, used at C:/Perl/site/lib/Net/SSH/Perl.pm line 218.

____
为什么会不匹配?1.99 是协议版本?而且我在将openssh从3.9 升级到4.6 还是个1.99  .ssh协议不是1/2吗
作者: crazymeny    时间: 2007-04-26 15:10
不管是3.9还是4.6,默认都是用protocol 1的,改/etc/ssh/sshd_config,去掉Protocol 2这行的注释,重启sshd服务再试试看吧。
作者: cc964894    时间: 2007-04-26 15:44
谢谢你的帮助。
试过的结果很遗憾。
我个人认为问题应该不在这里。因为这个[SSH::PERL]的出错提示为 protocol为1.99,与xxx不匹配。可能问题就不在ssh了。
首先这个提示“protocol v1.99”获取的是否正确?
我在搜到bbs里以前有人发过帖子,是关于该模块在执行dos命令的问题。


至于sshd的协议版本 其实openssl4.6 协议默认是“ 2,1”的,也就是先用v2协商,不行就用v1的。
作者: ulmer    时间: 2007-04-26 16:30
原帖由 cc964894 于 2007-4-26 14:35 发表
...
: Remote protocol version 1.99, remote software version OpenSSH_4.6
: Net::SSH::Perl Version 1.23_01, protocol version 2.0.
: No compat match: OpenSSH_4.6.
...


Hi,

the key error is:
remote ssh 's protocol  belong to V1, but you set "protocol =>2 " in your perlcode:
new($host,protocol =>2,...

Try to set protocol =>1 or protocol=>'1, 2'

Reading more about SSH-1 /SSH-2 in perldoc  Net::SSH::Perl

Good luck,
-- ulmer
作者: crazymeny    时间: 2007-04-26 17:29
原帖由 cc964894 于 2007-4-26 15:44 发表
谢谢你的帮助。
试过的结果很遗憾。
我个人认为问题应该不在这里。因为这个[SSH::PERL]的出错提示为 protocol为1.99,与xxx不匹配。可能问题就不在ssh了。
首先这个提示“protocol v1.99”获取的是否正确?
...



你确定把sshd_config里的

#Protocol 2,1

改成

Protocol 2

并重启了sshd服务?这样强制运行在protocol 2是不可能取得“protocol v1.99”返回值的
至于运行在哪个版本,telnet一下22端口就知道了
作者: crazymeny    时间: 2007-04-26 18:25
协议默认是“ 2,1”的,也就是先用v2协商,不行就用v1的。

确实是这样

telnet一下22端口就知道了

这个我弄错了,这样测试不严谨,不能误导后来人

Protocol 2,1/Protocol 2我都测了一下,没遇到LZ的问题,用的Net::SSH::W32Perl
作者: cc964894    时间: 2007-05-16 16:26
恩。 谢谢大家
后来在测试的过程中,发现了问题的所在。
其实我用的就是W32PERL,因为我也是win box
错在应该把帖中代码修改:
use Net::SSH::W32Perl;
my $ssh = Net::SSH::W32Perl->new( .....




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2