【发布时间】: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