Updated: 30 September 2026 · Applies to: PECL ssh2 1.5.0 with EasyApache 4 PHP 8.1 to 8.4 on cPanel & WHM 138 (AlmaLinux, Rocky Linux, CloudLinux 9)

The PHP ssh2 extension lets PHP scripts connect to other servers over SSH and SFTP, for example to upload backups or run remote commands. EasyApache 4 has no ready-made package for it, so you build it with PECL for each PHP version that needs it. It is built against the libssh2 library. We checked the packages on a cPanel & WHM 138 server and built ssh2 1.5.0 on AlmaLinux 9.

1. Install the libssh2 headers

On AlmaLinux, Rocky Linux and CloudLinux 9, libssh2-devel comes from EPEL:

dnf install epel-release
dnf install libssh2-devel

2. Build the extension for each PHP version

In WHM, open Software > Module Installers, click Manage next to PHP Pecl, choose the PHP version, search for ssh2 and install it. Repeat for every PHP version your sites use.

From the command line, use the PECL tool of the EasyApache PHP version, for example PHP 8.3. Downloading the release file first avoids problems with the PECL channel:

cd /usr/local/src
curl -O https://pecl.php.net/get/ssh2-1.5.0.tgz
/opt/cpanel/ea-php83/root/usr/bin/pecl install ssh2-1.5.0.tgz

Press Enter when it asks for the libssh2 prefix, to use the automatic detection.

3. Check that it is loaded

/opt/cpanel/ea-php83/root/usr/bin/php -m | grep ssh2

If it is not listed, add the line extension=ssh2.so to /opt/cpanel/ea-php83/root/etc/php.d/zzzzzzz-pecl.ini. Then restart PHP-FPM for sites that use it:

/usr/local/cpanel/scripts/restartsrv_apache_php_fpm

A quick test: /opt/cpanel/ea-php83/root/usr/bin/php -r 'var_dump(function_exists("ssh2_connect"));' should print bool(true).

Alternatives

Many applications do not need the extension at all: the pure-PHP library phpseclib (installed with Composer) supports SSH and SFTP without compiling anything, and survives PHP upgrades without rebuilding.

After a major PHP update in EasyApache, check php -m again and reinstall the extension if needed.

Official documentation: PECL ssh2 and PHP manual: SSH2.

Related services

Managed cPanel VPS

cPanel included; we handle updates, security and monitoring.

cPanel server management

hardening, migrations and 24/7 monitoring, with no long-term contract.

cPanel, Plesk and LiteSpeed licences

for VPS and dedicated servers, with installation help on demand.

Was this answer helpful?

Still stuck? Open a ticket