zoukankan      html  css  js  c++  java
  • 安装Net::SSH::Perl (更好用的模块Net::OpenSSH)

    Net::SSH::Perl

    这个模块,安装起来需求比较多,使用cpan安装的话,还有一些问题,比如比较常见的:

    卡在

    Math::BigInt: couldn't load specified math lib(s), fallback to Math::BigInt::Calc at /usr/lib/perl5/site_perl/5.8.8/Crypt/DH.pm line 6

    这时使用ctrl+c,cpan会跳过这个模块,继续安装下面的模块,然后到cpan.org下载crypt::DH模块,进行手动安装,就可以了。

    这个模块儿本身有些问题,因为在使用过程中会报错:

    Math::BigInt: couldn't load specified math lib(s), fallback to Math::BigInt::Calc at /usr/lib/perl5/site_perl/5.8.8/Crypt/DH.pm line 6

    需要打开/usr/lib/perl5/site_perl/5.8.8/Crypt/DH.pm,修改第六行,将use Math::BigInt lib => "GMP,Pari"; 其中的lib改为try,即可正常使用

    解决链接远程主机慢的问题

    网上说要安装三个东西:
    YAML
    Math::BigInt
    Math::BigInt::GMP

    之前已经安装完 YAML 和  Math::BigInt 了,在装完 Math::BigInt::GMP 后测试,在与远程主机的连接过程中,速度明显提升(连接到远程主机后操作时间不变)。

    这个模块,发现一个问题,无法支持在私钥验证情况下的密码输入,可以选择Net::OpenSSH这个模块,依赖模块IO::Pty,基本也可以完成上面的功能。

    #!/usr/bin/perl
    use strict;
    use Net::OpenSSH;
    my $host='www.xxx.com';
    my $user='name';
    my $passphrase='12345';
    my $key = '/root/.ssh/centos/id_rsa';
    my %param=(
        user => $user,
        passphrase => $passphrase,
        key_path => $key,
        timeout => 10,
        port => '22'
        );
    my $ssh = Net::OpenSSH->new($host,%param);
    #my ($rout, $pid) = $ssh->pipe_out("cat abc");
    my ($stdout,$stderr) = $ssh->system('df -h');
    print $stdout;
  • 相关阅读:
    搭建Elasticsearch 5.4分布式集群
    Elasticsearch中Head插件的使用
    Elasticsearch6.0及其head插件安装
    elasticsearch 6.2.3安装ik分词
    linux安装elasticsearch
    [Elasticsearch] 多字段搜索 (三)
    [Elasticsearch] 全文搜索 (一)
    [Elasticsearch] 多字段搜索 (二)
    elasticsearch this is not a http port
    基于visual Studio2013解决C语言竞赛题之0704字符串长度
  • 原文地址:https://www.cnblogs.com/agostop/p/2520036.html
Copyright © 2011-2022 走看看