PHPKonf Istanbul PHP Conference 2019 - Call for Papers


Windows binaries may be found at » To install, download php_ssh2.dll to the folder specified by your php.ini file's extension_dir directive. Enable it by adding extension=php_ssh2.dll to your php.ini and restarting your web server.


Linux, BSD, and other *nix variants can be compiled using the following steps:

  • Download and install » OpenSSL. If you install OpenSSL via your distribution's packaging system be sure to install the development libraries as well. This will typically be a package named openssl-dev, openssl_devel, or some variation thereof.
  • Download and install » libssh2. Typically this means executing the following command from the libssh2 source tree. ./configure && make all install.
  • Run the pecl installer for PECL/ssh2: pecl install ssh2
  • Copy from the directory indicated by the build process to the location specified in your php.ini file under extension_dir.
  • Add to your php.ini
  • Restart your web server to reload your php.ini settings.

Забележка: Development Versions
There are currently no stable versions of PECL/ssh2, to force installation of the beta version of PECL/ssh2 execute: pecl install ssh2-beta


Compiling PECL/ssh2 without using the PECL command

Rather than using pecl install ssh2 to automatically download and install PECL/ssh2, you may download the tarball from » PECL. From the root of the unpacked tarball, run: phpize && ./configure --with-ssh2 && make to generate Once built, continue the installation from step 4 above.

Информация относно инсталирането на това PECL разширение може да се намери в главата от ръководството Инсталиране на PECL разширения. Допълнителна информация, като нови издания, изтегляния, изходни файлове, информация за поддръжката и CHANGELOG може да се намери тук: »

Забележка: You will need version 0.4 or greater of the libssh2 library (possibly higher, see release notes).

add a note add a note

User Contributed Notes 15 notes

domenico dot campagnolo at gmail dot com
2 years ago
On Ubuntu 16.04 LTS

Using terminal as a root
     apt install php-ssh2
     service apache2 restart
zizifu at gmail dot com
6 years ago
CentOS 6.2 64bit Installation Steps:

1. download the libssh2 package from, command as following:
tar vxzf libssh2-1.4.2.tar.gz
cd libssh2-1.4.2
make install

2. download the php-ssh2 package from

tar vxzf ssh2-0.11.3
cd ssh2-0.11.3
./configure --with-ssh2
make install

and the file will copy into /usr/lib64/php/modules
check it.

3. modify the php.ini

vi /etc/php.ini

add the "" to the extension part of php.ini

4. check the environment of php, use phpinfo();

5. enjoy
warkirasep dot puloh at gmail dot com
2 years ago
Installation For Centos 5.11 x86_64

1. Update your repo


rpm --import

rpm -K rpmforge-release-0.5.3-1.el5.rf.*.rpm

rpm -i rpmforge-release-0.5.3-1.el5.rf.*.rpm

2. yum install gcc php-devel php-pear libssh2 libssh2-devel
3. pecl install -f ssh2
4. Enable extension from php.ini configuration

5. Restart HTTPD

/etc/init.d/httpd restart

6. Chek PHP module

php -m

Good Luck
dreadwestern at gmail dot com
6 years ago
Steps for installing the extension package on Debian systems:

> sudo apt-get install libssh2-php
> sudo /etc/init.d/apache2 restart
stanislav dot eckert at vizson dot de
2 years ago
[Editor's note: unless you have special demands, use the appropriate deps package from <>.]

SSH2 for Windows is not available from the authors of the extension. But compiled binaries are available from the Apache Lounge (which is recommended by the website too).

Link for PHP 5.3, 5.4, 5.5, 5.6 and 7.0:

This binaries contain a lot (maybe even all?) for Windows compiled PHP extensions, like the SSH2 extension.

Please note that it is also highly recommended to use their Windows binary builds for the Apache HTTP server from here:

Older versions can be choosen from the left menu (VC11, VC10, etc.) if required. also recommends to use the binary builds from the Apache Lounge.

Maybe this helps developers, who work with Windows and can't find or compile some extensions themself.
stanislav dot eckert at vizson dot de
2 years ago
Since version 0.12 (released 2012-10-15) there is a binary version for Windows.

See here:

I tested it with PHP 5.5.29 (32-bit, thread-safe) on my Windows 7 machine.
francewhoa+php dot net at ubertus dot ca
3 years ago
Steps to install "ssh2" on Debian Jessie 8

1. Using Terminal as Root. Run the following command to install the extension package.

apt-get install php5-ssh2

2. Restart Apache2 server

service apache2 restart
1 year ago
Steps for installing on CentOS Linux 7

After having a full webserver running, install packages libssh2.x86_64 and php-pecl-ssh2.x86_64

1. yum install libssh2.x86_64 php-pecl-ssh2.x86_64
2. systemctl restart httpd.service
2 years ago
Steps for installing the extension package on Ubuntu 14.04.

Very similar to dreadwestern at gmail dot com recipe, but enable ssh2 in PHP:

> sudo apt-get install libssh2-php
>  php5enmod ssh2
> sudo /etc/init.d/apache2 restart
kurdtpage at gmail dot com
5 months ago
The SSH2 binary for Windows (php_ssh2.dll) can be found here:
imedina at grosshat dot com
8 years ago
Using PECL it must be specified the channel, since the beta version has to be choosen instead of stable one:

$ pecl install ssh2 channel://
sadhooklay AT
3 years ago
Installing on Ubuntu 14.0.4

    sudo pecl channel-update
    sudo apt-get install libssh2-1-dev
    sudo pecl install -a ssh2-0.12
    echo '' | sudo tee /etc/php5/mods-available/ssh2.ini > /dev/null
    sudo php5enmod ssh2
warpman at gmail dot com
4 years ago
Installing this module for use with CentOS 5.?? or 6.?

1. Install your favorite PHP RPM packages.  Make sure that one of your favorite packages is pear, so pecl gets installed in-tow.

2. Find and install *RPMS* of libssh2 of a version >= 1.2, get both the base lib package (libssh2-1.2.*.rpm) and the devel package that includes headers (libssh2-devel-1.2.*.rpm) of the EXACT SAME VERSION.  Finding these packages took a few minutes of googling, and I invite an editor that has a trusted source for these to attach URLs as appropriate. (Yes, the version below is ancient)

# rpm -ivh libssh2-1.2.6-1.el5.rf.x86_64.rpm libssh2-devel-1.2.6-1.el5.rf.x86_64.rpm

3. Install the PHP module via pecl
# pecl install ssh2-0.12

4. Make PHP see the newly-installed extension
# echo "" > /etc/php.d/ssh2.ini

5. Restart apache
chris at 3menandarecorder dot com
10 years ago
To help someone avoid the headaches I did for a week. SSH2 functions have problems with the ssh2-beta & libssh2-0.18 even after patching with said patches on the internet.

ssh_exec will work fine
ssh2_shell will not work

In order to use ssh2_shell I had to roll back to libssh2-0.14 in order to get ssh2_shell function to work properly
arie dot mail at gmail dot com
10 years ago
Just a little note: when compiling this package after modifying the ssh2.c, do not use pecl build as it will not create an file (although it says it succeeded), use:

./configure --with-ssh2

you then need to copy the file into your extension dir if it didn't do so already.
To Top