免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2302 | 回复: 6
打印 上一主题 下一主题

请教关于WIN下 Net::SSH::Perl 的问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-04-26 14:35 |只看该作者 |倒序浏览
在测试该模块的时候出现了一个问题
代码:(模块来自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吗

论坛徽章:
0
2 [报告]
发表于 2007-04-26 15:10 |只看该作者
不管是3.9还是4.6,默认都是用protocol 1的,改/etc/ssh/sshd_config,去掉Protocol 2这行的注释,重启sshd服务再试试看吧。

论坛徽章:
0
3 [报告]
发表于 2007-04-26 15:44 |只看该作者
谢谢你的帮助。
试过的结果很遗憾。
我个人认为问题应该不在这里。因为这个[SSH::PERL]的出错提示为 protocol为1.99,与xxx不匹配。可能问题就不在ssh了。
首先这个提示“protocol v1.99”获取的是否正确?
我在搜到bbs里以前有人发过帖子,是关于该模块在执行dos命令的问题。


至于sshd的协议版本 其实openssl4.6 协议默认是“ 2,1”的,也就是先用v2协商,不行就用v1的。

论坛徽章:
0
4 [报告]
发表于 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

论坛徽章:
0
5 [报告]
发表于 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端口就知道了

论坛徽章:
0
6 [报告]
发表于 2007-04-26 18:25 |只看该作者
协议默认是“ 2,1”的,也就是先用v2协商,不行就用v1的。

确实是这样

telnet一下22端口就知道了

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

Protocol 2,1/Protocol 2我都测了一下,没遇到LZ的问题,用的Net::SSH::W32Perl

论坛徽章:
0
7 [报告]
发表于 2007-05-16 16:26 |只看该作者
恩。 谢谢大家
后来在测试的过程中,发现了问题的所在。
其实我用的就是W32PERL,因为我也是win box
错在应该把帖中代码修改:
use Net::SSH::W32Perl;
my $ssh = Net::SSH::W32Perl->new( .....
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP