Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to install Net:SSH2 Perl module, but I run in this error:

[root@script-server fmzbih_cms_weather_updater]# cpanm Net::SSH2
--> Working on Net::SSH2
Fetching ... OK
Configuring Net-SSH2-0.44 ... OK
Building and testing Net-SSH2-0.44 ... FAIL
! Installing Net::SSH2 failed. See /root/.cpanm/build.log for details.
[root@script-server fmzbih_cms_weather_updater]# cat /root/.cpanm/build.log
cpanm (App::cpanminus) 1.5011 on perl 5.014002 built for i686-linux-thread-multi
Work directory is /root/.cpanm/work/1335442976.25013
You have make /usr/bin/make
You have LWP 6.04
You have /bin/tar: tar (GNU tar) 1.15.1
You have /usr/bin/unzip
Searching Net::SSH2 on cpanmetadb ...
--> Working on Net::SSH2
-> OK
Unpacking Net-SSH2-0.44.tar.gz
Entering Net-SSH2-0.44
Checking configure dependencies from META.yml
Checking if you have ExtUtils::MakeMaker 6.59 ... Yes (6.62)
Configuring Net-SSH2-0.44
Running Makefile.PL
Subroutine checklibs redefined at inc/Module/Install/ line 11.
Subroutine assertlibs redefined at inc/Module/Install/ line 25.
Subroutine _author_side redefined at inc/Module/Install/ line 39.

The libssh2 library is required by this module.  If you don't have it, you can
download it from; you may also need OpenSSL, which can be
obtained from

Debian:   sudo aptitude install libssh2-1-dev
OpenSUSE: sudo zypper in libssh2-1 libssh2-devel

You can pass your libssh2 lib and include dirs on the command line. E.g.:

    perl Makefile.PL lib=$HOME/libssh2/lib inc=$HOME/libssh2/include

If you want to build on Windows, see the file BUILDING.WIN32 in the

Checking if your kit is complete...
Looks good
Writing Makefile for Net::SSH2
Writing MYMETA.yml and MYMETA.json
-> OK
Checking dependencies from MYMETA.json ...
Checking if you have ExtUtils::MakeMaker 6.59 ... Yes (6.62)
Building and testing Net-SSH2-0.44
cp lib/Net/SSH2/ blib/lib/Net/SSH2/
cp lib/Net/SSH2/ blib/lib/Net/SSH2/
cp lib/Net/SSH2/ blib/lib/Net/SSH2/
cp lib/Net/SSH2/ blib/lib/Net/SSH2/
cp lib/Net/SSH2/ blib/lib/Net/SSH2/
cp lib/Net/SSH2/ blib/lib/Net/SSH2/
cp lib/Net/ blib/lib/Net/
AutoSplitting blib/lib/Net/ (blib/lib/auto/Net/SSH2)
/usr/local/bin/perl "-Iinc" /usr/local/lib/perl5/5.14.2/ExtUtils/xsubpp  -typemap /usr/local/lib/perl5/5.14.2/ExtUtils/typemap -typemap typemap  SSH2.xs > SSH2.xsc && mv SSH2.xsc SSH2.c
cc -c  -I/usr/local/include -I/usr/include -I. -D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2   -DVERSION=\"0.44\" -DXS_VERSION=\"0.44\" -fPIC "-I/usr/local/lib/perl5/5.14.2/i686-linux-thread-multi/CORE"   SSH2.c
Running Mkbootstrap for Net::SSH2 ()
chmod 644
rm -f blib/arch/auto/Net/SSH2/
LD_RUN_PATH="/usr/lib:/lib" cc  -shared -O2 -L/usr/local/lib -fstack-protector SSH2.o  -o blib/arch/auto/Net/SSH2/   \
       -L/root -L/usr/local/lib -L/lib -L/usr/lib -L/usr/local/lib -L/usr/local -L/usr/lib -L/usr -L/opt -L//lib -L/ -lssh2 -lz -lssl -lcrypto      \

/usr/bin/ld: cannot find -lz
collect2: ld returned 1 exit status
make: *** [blib/arch/auto/Net/SSH2/] Error 1
-> FAIL Installing Net::SSH2 failed. See /root/.cpanm/build.log for details.

Seems like I am unable to compile something due to glibc static linking. However, I don't know what's alternative for glibc-static on CentOS 5.

share|improve this question
Do you have the required library libssh2-dev? – Khaled Apr 26 '12 at 12:58
Hi, I do - i just checked libssh2-devel is there and updated to latest version. – Zec Apr 26 '12 at 13:05
I've edited your pastebin text into your answer and wrapped it in code markup to preserve formatting/linebreaks. Please do this in the future instead of linking to an external site. In a year or more when someone stumbles on this question with the same problem, there's no guarantee that pastbin will still host the output, but if you put it in the question, it's guaranteed to exist as long as the question does. – MDMarra Apr 26 '12 at 13:52
up vote 3 down vote accepted

Your system is missing the gzip library development files.


yum install zlib-devel

... that should resolve your issue.

share|improve this answer
I was missing zlib actually, and your answer Sir lead me to the good trail. Thank you! Now I am having "/usr/bin/ld: cannot find -lssl" and I don't know again which lib I am missing, as I used different linux distro before. – Zec Apr 26 '12 at 13:15
Your new problem is that you are missing openssl and/or openssl-devel packages. – Janne Pikkarainen Apr 26 '12 at 13:23
True. Thanks again! Got it working but now don't know how to tell Perl to use Net::SSH2 instead of Net::SSH. – Zec Apr 26 '12 at 14:03

I do tend to use CPAN over the system package managers for perl modules, because CPAN will recursively download and build required dependencies.

cpan man cpan

share|improve this answer
I am actually using cpan minus (cpanm) to manage all CPAN modules. However, I got stuck when executing "cpanm Net::SSH2". Do you know how can I tell Perl not to use Net::SSH and use Net::SSH2 instead? – Zec Apr 26 '12 at 14:02

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.