【问题标题】:Net::SSH2 with Windows SSH agentNet::SSH2 与 Windows SSH 代理
【发布时间】:2022-11-22 11:42:55
【问题描述】:

我目前正在处理 Simpack 和 HPC 集群服务器之间的连接。我必须将 perl 用于连接这两个服务的脚本。 我目前正在通过 SSH 将命令发送到服务器,但密钥需要加密。 我目前正在努力的解决方案是使用 Net:SSH2 (libssh2) 并使其从 Windows SSH 服务获取密钥。 SSH 服务在 CMD 中使用时效果很好,但在 perl 中我收到以下错误:failed connecting agent (-42 LIBSSH2_ERROR_AGENT_PROTOCOL) at .\sshtest.pl line 7。

我不知道问题出在哪里,非常感谢任何帮助。 这段代码基本上包含了我从模块中需要的一切:

use Net::SSH2;
 
my $ssh2 = Net::SSH2->new();
$ssh2->connect('IP here')
    or $ssh2->die_with_error;
$ssh2->auth_agent('username here')
    or $ssh2->die_with_error;
my $chan = $ssh2->channel()
  or $ssh2->die_with_error;
$chan->exec('pwd')
  or $ssh2->die_with_error;
print while <$chan>;```

【问题讨论】:

标签: perl


【解决方案1】:

在 libssh2 的 1.10.0 版本中添加了对 Windows 上 OpenSSH 代理支持的支持。见libssh2 release notes

当我将 C API 与库的 1.9.0 版一起使用并更新到 1.10.0 版时,我注意到了这个错误。

【讨论】:

    猜你喜欢
    • 2015-12-03
    • 2012-11-14
    • 2018-10-02
    • 2015-10-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-10
    • 1970-01-01
    相关资源
    最近更新 更多