为什么 Perl 的 Net::SFTP->new 抱怨“不是 ARRAY 引用”?

发布于 2024-09-28 07:23:03 字数 567 浏览 4 评论 0原文

我正在尝试使用 Net::SFTP 连接到远程服务器。

我的脚本是:

my %args = ( 
    ssh_args => { 
       user => 'canneu_scp', 
       identity_files => [ '/home/home1/cgrshah/responsys/capgemini.private' ], 
       debug => 1, 
 } );

my $targetserver='files.responsys.net';

my $sftp = Net::SFTP->new($targetserver, %args) 
      or die "could not open connection to $targetserver\n";

但是当我运行此脚本时,我收到一条错误消息:

 Not an ARRAY reference at /usr/lib/perl5/site_perl/5.8.1/Net/SFTP.pm line 36.

任何人都可以帮助我吗?

I am trying to use Net::SFTP to get connected to remote server.

My script is:

my %args = ( 
    ssh_args => { 
       user => 'canneu_scp', 
       identity_files => [ '/home/home1/cgrshah/responsys/capgemini.private' ], 
       debug => 1, 
 } );

my $targetserver='files.responsys.net';

my $sftp = Net::SFTP->new($targetserver, %args) 
      or die "could not open connection to $targetserver\n";

But when I run this, I get an error stating:

 Not an ARRAY reference at /usr/lib/perl5/site_perl/5.8.1/Net/SFTP.pm line 36.

Can anyone help me with this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浅黛梨妆こ 2024-10-05 07:23:03

这只是一个盲目的猜测,但是 user 选项不应该位于传递给 ssh_args 的哈希中,它处于同一级别。尝试使用此代码:

my $sftp = Net::SFTP->new(
    $targetserver,
    user     => 'canneu_scp', 
    ssh_args => { 
        identity_files => [ '/home/home1/cgrshah/responsys/capgemini.private' ], 
        debug => 1,
    } 
) or die "could not open connection to $targetserver\n";

听起来上面的代码让您更进一步,但现在您遇到了问题,因为您的 Math::BigInt 太旧了。我看到了三种前进的方法:

  1. 切换到 RSA 密钥而不是 DSA 密钥
  2. 找到 Math::BigInt 版本 1.78 或更高版本的 RPM
  3. 手动安装 Math::BigInt< 的副本/code>

第三个选项有很多陷阱,如果您决定使用它,我建议执行以下步骤:

  1. 安装 App::cpanminus
    1. 确保您安装了 gcc
    2. 运行wget -O- http://cpanmin.us | perl - --local-lib=~/perl5 App::cpanminus
    3. ~/perl5/bin 添加到您的路径
  2. Math::BigInt 安装到您的家中使用 cpanm --local-lib=~/perl5 Math::BigInt 的目录
  3. use lib "$ENV{HOME}/perl5"; 添加到脚本的开头,以便它可以找到新模块

This is just a wild shot in the dark, but the user option should not be in the hash handed to ssh_args, it is at the same level. Try using this code instead:

my $sftp = Net::SFTP->new(
    $targetserver,
    user     => 'canneu_scp', 
    ssh_args => { 
        identity_files => [ '/home/home1/cgrshah/responsys/capgemini.private' ], 
        debug => 1,
    } 
) or die "could not open connection to $targetserver\n";

It sounds like the code above got you further along, and now you are having problems because your version of Math::BigInt is too old. I see three ways to move forward:

  1. switch to an RSA key instead of a DSA key
  2. find an RPM of Math::BigInt version 1.78 or later
  3. manually install a copy of Math::BigInt

The third option has many pitfalls, and if you decide to go with it I would suggest the following steps:

  1. install App::cpanminus
    1. make sure you have a gcc installed
    2. run wget -O- http://cpanmin.us | perl - --local-lib=~/perl5 App::cpanminus
    3. add ~/perl5/bin to your path
  2. install Math::BigInt into your home directory with cpanm --local-lib=~/perl5 Math::BigInt
  3. add use lib "$ENV{HOME}/perl5"; to the start of your script so it can find the new modules
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文