Friday, March 25, 2011

perl experience - ssh installation

Net::SSH::Perl
Net::SSH2
Net::OpenSSH


Problem:
Math::BigInt: couldn't load specified math lib(s), fallback to Math::BigInt::FastCalc at /opt/local/lib/perl5/site_perl/5.12.3/Crypt/DH.pm line 6

Workaround:
reinstall
Math::BigInt::GMP
Math::BigInt::Pari
Math::BigInt::BitVector (no such thing)

Reference:
http://www.perlmonks.org/?node_id=664894



問題 1:
Can't locate object method "new" via package "Net::SSH::Perl" (perhaps you forgot to load "Net::SSH::Perl"?) at rbt.pl line 28.
解決方法:
透過 perl -V 得知
@INC:
    /etc/perl
    /usr/local/lib/perl/5.10.1
    /usr/local/share/perl/5.10.1
    /usr/lib/perl5
    /usr/share/perl5
    /usr/lib/perl/5.10
    /usr/share/perl/5.10
    /usr/local/lib/site_perl
    .
發現有一個 /etc/perl/Net/SSH/Perl.pm -> /usr/share/perl5/Net/SSH.pm, 而它的版本是 0.09
而 Net::SSH::Perl 目前版本為 1.35
所以 mv /etc/perl/Net/SSH/Perl.pm to /etc/perl/Net/SSH/Perl.pm.deprecated

問題 2:
在 cpan, install Net::SSH::Perl
跑到最後,
Running make for S/SC/SCHWIGON/Net-SSH-Perl-1.35.tar.gz
  Has already been unwrapped into directory /root/.cpan/build/Net-SSH-Perl-1.35-NKUlxh

  CPAN.pm: Building S/SC/SCHWIGON/Net-SSH-Perl-1.35.tar.gz

Warning: Prerequisite 'Crypt::RSA => 1.37' for 'SCHWIGON/Net-SSH-Perl-1.35.tar.gz' failed when processing 'VIPUL/Crypt-RSA-1.99.tar.gz' with 'make_test => NO 2 dependencies missing (Tie::EncryptedHash,Crypt::CBC); additionally test harness failed'. Continuing, but chances to succeed are limited.
make: Warning: File `Makefile.PL' has modification time 1e+06 s in the future
Makefile out-of-date with respect to Makefile.PL
Cleaning current config before rebuilding Makefile...
make -f Makefile.old clean > /dev/null 2>&1
/usr/bin/perl Makefile.PL "INSTALLDIRS=site"
This is Net::SSH::Perl.

As of version 1.00, Net::SSH::Perl supports both the SSH1 and
SSH2 protocols natively. The two protocols have different
module prerequisitives, so you need to decide which protocol(s)
you plan to use. If you use one or the other, only those modules
for your chosen protocol will be installed; if you choose both,
all of the supporting modules will be installed. Please choose
the protocols you'd like to use from the following list ("Both"
is the default).

    [1] SSH1
    [2] SSH2
    [3] Both SSH1 and SSH2

Which protocol(s) do you plan to use? [3]

Some of the Net::SSH::Perl ciphers depend on a Crypt:: module from
CPAN. You may already have the necessary modules installed, in which
case you don't need to bother with this step. Otherwise you'll need
to install at least one cipher to use Net::SSH::Perl. Please choose
at least one from the following list (Crypt::IDEA is the default).

    [1] IDEA
    [2] DES
    [3] DES3
    [4] Blowfish
    [5] RC4

Enter your choices, separated by spaces: [1]

Checking for optional modules

Crypt::RSA is required if you wish to use the ssh-rsa public
key algorithm (ssh-dss is used by default).

Would you like to install it? (y/n) [y]

Checking if your kit is complete...
Looks good
Warning: prerequisite Crypt::RSA 1.37 not found.
Writing Makefile for Net::SSH::Perl
Writing MYMETA.yml and MYMETA.json
==> Your Makefile has been rebuilt. <==
==> Please rerun the make command.  <==
false
make: *** [Makefile] Error 1
  SCHWIGON/Net-SSH-Perl-1.35.tar.gz
  /usr/bin/make -- NOT OK
Running make test
  Can't test without successful make
Running make install
  Make had returned bad status, install seems impossible
Failed during this command:
 LDS/Crypt-CBC-2.32.tar.gz                    : make NO
 VIPUL/Tie-EncryptedHash-1.24.tar.gz          : make_test NO one dependency not OK (Crypt::CBC); additionally test harness failed
 VIPUL/Crypt-RSA-1.99.tar.gz                  : make_test NO 2 dependencies missing (Tie::EncryptedHash,Crypt::CBC); additionally test harness failed
 SCHWIGON/Net-SSH-Perl-1.35.tar.gz            : make NO

簡單說, 從倒數幾行提到以下幾個 depency 安裝失敗
Crypt-CBC-2.32
Tie-EncryptedHash-1.24
Crypt-RSA-1.99

解決方法:
到 ~/.cpan/build/ 找到相對應的資料夾內, 依序執行
>perl Makefile.PL
產生  Makefile, 如果有出現 depency 問題, 再逐一解決 depency 問題, 直到沒有再出現 depency 的問題
>make
如果 make fail, 如果是缺乏 library, 則安裝該 library, 如果 library 版本太舊, 則下載 library 源始碼, 自行編譯, 再安裝, 再重新跑 perl Makefile.PL
>make install
如果 make 沒問題, 執行 install

For example, when building Math::GMP, there was an error concerning
"GMP.xs:4:17: error: gmp.h: No such file or directory",
the solution is to
"apt-get install libgmp3-dev"

No comments: