【问题标题】:Net::SSH perl script for windows 7Windows 7 的 Net::SSH perl 脚本
【发布时间】:2015-10-08 14:36:18
【问题描述】:

我正在使用 windows 64 位活动 perl 5.20 sw 登录 linux/unix 服务器。 在同一台 Windows 机器上,我可以毫无问题地使用我的用户名和密码进行 ssh。但是当我使用以下脚本时,我得到了 权限被拒绝

(gssapi-keyex、gssapi-with-mic、公钥、密码、键盘交互)。

知道如何解决它吗? 谢谢

  #!/Perl64/bin/

   use strict;
   use Net::SSH qw(sshopen2);
   use strict;

   my $host = '10.120.xx.xx';
   my $user = 'user';
   my $pass = 'password';
   my $cmd = '/bin/sh';
   my @commands = ('df -k','free','uptime');

   sshopen2("$user\@$host", *READER, *WRITER, "$cmd") || die "ssh: $!";

   while (<READER>) {
      chomp();
      print "$_\n";
   }

   close(READER);
   close(WRITER);

【问题讨论】:

  • 远程主机的密码在哪里提供?

标签: perl


【解决方案1】:

sshopen2 不支持密码。它在 perldoc 页面中进行了解释:http://search.cpan.org/dist/Net-SSH/SSH.pm (见常见问题解答)

建议要么设置 rsa 密钥,要么使用模块 expect(模仿用户输入)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-29
    • 2016-08-16
    • 2020-01-06
    • 2013-08-04
    • 1970-01-01
    • 2011-02-20
    相关资源
    最近更新 更多