+ -
当前位置:首页 → 问答吧 → Net::SSH::Expect SSHAuthenticationError Login timed out.

Net::SSH::Expect SSHAuthenticationError Login timed out.

时间:2010-09-29

来源:互联网


错误信息:SSHAuthenticationError Login timed out. The input stream currently has the contents bellow:  at /usr/lib/perl5/site_perl/5.8.8/Expect.pm line 828
代码
  1. #!/usr/bin/env perl
  2. use Net::SSH::Expect;
  3. use strict;

  4. my $i;
  5. my $command=$ARGV[1];
  6. for($i=0;$i<$ARGV[0];$i++){
  7.         my $ip=$ARGV[$i+2];
  8.         print $ip;
  9.         my $ssh=Net::SSH::Expect->new(
  10.                 host => $ip,
  11.                 password => '******',
  12.                 user => 'root',
  13.                 raw_pty => 1
  14.         );
  15. $ssh->login();
  16. #if ($login_output !~ /Weclome/){
  17. #       die "Login has failed.Login output was $login_output";
  18. #}
  19.         my $job=$ssh->exec($command);
  20.         print ($job);
  21.         $ssh->close();
  22. }
复制代码
$./ssh.pl 2 "ls -l /" "node1" "node2"

作者: Mr-Summer   发布时间: 2010-09-29

这个问题是解决了,是他们在给node间的ssh登入配置了互信,所以用without password的方式就可以了。


我还有个问题,想打包这个小程序是不是只能把(Net::SSH::Expect.pm,Expect 1-12.pm,IO::Tty.pm三个模块和ssh.pl放在同一文件夹中,在require),有更方便的模块或者方法不?

作者: Mr-Summer   发布时间: 2010-09-29

热门下载

更多