Net::SSH2 perl module using libssh2
C Perl XS
Latest commit af3d7f0 Dec 13, 2017 @salva salva Prepare for release 0.68


Net::SSH2 - Secure Shell protocol interface

Net::SSH2 is a perl interface to the libssh2 (
library.  It supports the SSH2 protocol (there is no support for SSH1)
with all of the key exchanges, ciphers, and compression of libssh2.
At present, libssh2 requires OpenSSL ( and can
optionally use zlib for compression (


To install modules that Net::SSH2 depends upon type the following:

   cpanm Module::Install Module::Install::CheckLib IO::Scalar Term::ReadKey


This module also requires these libraries:

   libssh2 (; recommended to use version 1.7.0 or later)
   OpenSSL (
   zlib (optional;

To install dependencies:

Debian:   sudo aptitude install libssh2-1-dev libssl-dev
OpenSUSE: sudo zypper in libssh2-1 libssh2-devel
OS X homebrew: brew install libssh2


To install Net::SSH2 type the following:

   perl Makefile.PL
   make test
   make install


Please report bugs and request features on the CPAN bug tracking site,  If you are able and willing to provide a fix, attach a patch
and please provide your name to be credited in the changelog and an email
address for verification/discussion.

The ssh-sftp-perl-users mailing list
while set up for Net::SSH::Perl, is also an appropriate place to post
questions or comments about Net::SSH2.


You can run more extensive tests with the following command:

   perl -Mblib t/Net-SSH2.t

This will prompt you for a hostname and subsequently a username to
test connecting with. You can use localhost, a remote hostname or an
IPv4 or IPv6 address.

There are some tests (SCP) that require IO::Scalar installed to run.


The module is kept in a GitHub (
repository, git://

If you are interested in making a change/fix, please discuss it first.  If you
are unfamiliar with XS (perl C bindings), you should review the perlxs,
perlapi, and perlcall perldoc pages to learn more.  The secure shell protocol
is managed by the IETF secsh working group at  The source code of
libSSH2 will also be instructive.


More examples for the example/ directory would be nice.

Add get/put (file) methods to Net::SSH2::SFTP (as a shortcut, rather than 
requiring open/read/write/close).


Copyright (C) 2005-2008 by David B. Robins.

Copyright (C) 2010-2016 by Rafael Kitover (

Copyright (C) 2011-2017 by Salvador Fandino (

All rights reserved.

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version 5.8.0 or,
at your option, any later version of Perl 5 you may have available.