1

So I am trying to run a perl script on my Centos machine. I have tried on Centos 5,6,7 with no success. Every time I run the script I get this:

Can't locate Net/SSH2.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .)

I have installed libssh2

Package libssh2-1.4.3-12.el7.x86_64 already installed and latest version

I have tried using cpan but no matter what I do it doesn't seem to work. I just don't understand why perl isn't finding the module... Am I missing something? If somebody could guide me to actually installing the SSH2 module because I have looked everywhere and nothing seems to work. Thanks in advance.

UPDATE: When I try to install via cpan:

cpan[1]> install Net::SSH2
Reading '/root/.cpan/Metadata'
Reading '/root/.cpan/sources/authors/01mailrc.txt.gz'
........................................................................DONE
Reading '/root/.cpan/sources/modules/02packages.details.txt.gz'
Database was generated on Fri, 04 Jan 2019 22:17:03 GMT
HTTP::Date not available
.............
New CPAN.pm version (v2.22) available.
[Currently running version is v1.9800]
You might want to try
install CPAN
reload cpan
to both upgrade CPAN.pm and run the new version without leaving
the current session.


........................................Killed

Still getting the same error...

BogusFeet
  • 31
  • 1
  • 8
  • `install Net::SSH2`, not `install Net::SH2`. Though I'd see if it's available as a package in the centos repository before installing manually. – Shawn Jan 06 '19 at 11:37
  • It's still now working... I don't think my cpan is working at all tbh, everything I type into it gives me the exact same response as you can see in my original post. I try googling but I can't find anything useful... – BogusFeet Jan 06 '19 at 16:16

2 Answers2

4

libssh is the C library for SSH. Net::SSH2 is a Perl module. They are different piece of software (although Net::SSH2 probably depends on libssh).

You need to install Net::SSH2.

See What's the easiest way to install a missing Perl module?

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
1

As Quentin mentioned in his answer, libssh2 is the C library for SSH, whereas Net::SSH2 is a Perl module. Since Net::SSH2 will be installed from source (which is what the cpan command does in the background), you will need to ensure that a few prerequisites are installed:

sudo yum install libssh2 libssh2-devel gcc

The libssh2 package was added to this list for completeness. The development package for libssh2 (libssh2-devel) as well as gcc (a C compiler) are required, since the process of installing Net::SSH2 from source requires a library to be built so that Net::SSH2 can talk to libssh2.

When Perl modules are installed from source, the module's test suite is run by default to check that everything is ok before actually running the install step. Hence, you will need to ensure that perl-Test-Simple is installed, since Net::SSH2 uses this to run its tests:

sudo yum install perl-Test-Simple

I personally find it much easier to install Perl modules via cpanm than cpan, thus I recommend installing it (it's available as a yum package):

sudo yum install perl-App-cpanminus

Now the installation of Net::SSH2 should be as simple as:

cpanm Net::SSH2

If you want to install the module system-wide, then you will need to prefix the cpanm call with sudo:

sudo cpanm Net::SSH2
ptc
  • 71
  • 4