In the examples shown, replace "X.Y" with your app's PHP version (for example, "5.4" or "7.1"). To install a PECL extension for multiple PHP versions, repeat the PECL extension installation for each PHP version.

The SSH2 extension provides functions for accessing remote machines using the secure SSH and SFTP protocols.

Installing the SSH2 Extension on PHP 5

To install this extension on PHP 5.4, 5.5, or 5.6, SSH in as root and run the following on your server:

sudo apt-get install gcc make autoconf libc-dev pkg-config
sudo apt-get install libssh2-1-dev
sudo pecl5.X-sp install ssh2

Once installed, create a configuration file for the extension and restart PHP.

sudo bash -c "echo extension=ssh2.so > /etc/php5.X-sp/conf.d/ssh2.ini"
sudo service php5.X-fpm-sp restart

Installing the SSH2 Extension on PHP 7

Note: The SSH2 extension's support for PHP 7 is currently in alpha.

To install this extension on PHP 7.0 or 7.1, SSH in as root and run the following on your server:

sudo apt-get install gcc make autoconf libc-dev pkg-config
sudo apt-get install libssh2-1-dev
sudo pecl7.X-sp install ssh2-alpha

Once installed, create a configuration file for the extension and restart PHP.

sudo bash -c "echo extension=ssh2.so > /etc/php7.X-sp/conf.d/ssh2.ini"
sudo service php7.X-fpm-sp restart

Verifying the Installation

You can verify the SSH2 extension is installed with the command:

phpX.Y-sp -i | grep ssh2

If SSH2 is installed correctly, you will see the following:

/etc/phpX.Y-sp/conf.d/ssh2.ini,
Registered PHP Streams => https, ftps, compress.zlib, compress.bzip2, php,
    file, glob, data, http, ftp, zip, phar, ssh2.shell, ssh2.exec,
    ssh2.tunnel, ssh2.scp, ssh2.sftp
ssh2
SSH2 support => enabled
libssh2 version => 1.4.3
banner => SSH-2.0-libssh2_1.4.3
Alert: For Control Panel Help & Tutorials, click here: Panel Tutorials
Was this answer helpful? 0 Users Found This Useful (0 Votes)