PHP SSH2 install

I have installed SSH2 with

dnf install libssh2-devel.x86_64

but I don’t see an extension enable in /etc/php.d. Does anyone have SSH2 working and how did you enable it?

What makes you think, that libssh2-devel has anything to do with PHP?
Iibssh2 is a C library! The -devel package contains the headers and libs, necessary to
compile programs written in C against libssh2.
See also:

Thanks for your helpful comment.

I was directed to install it by a support person at Omada Technologies…

“libssh2-devel-1.9.0-5.el8.x86_64 provides the ssh2 PHP extension. Install and enable it.”

That support person’s advice is plain wrong. What you are looking for is the PECL extension named SSH2.
Unfortunately, there is no such package available in in rocky8.

There is a package on Fedora, named php-pecl-ssh2 so IF you know how to package rpms yourself, with a little bit of luck you MIGHT (no guarantee) be able to download fedora’s src.rpm and rebuild for rocky with mock.

You have hit on my entire problem. My requirement is to use SSH from PHP on Rocky. I can’t find a way to get that working.

On rocky8 or rocky9?

Hi wesmat,
I just tested it and able to install ssh2 php extnetion in Rocky Linux 8.

root@rocky ~]# php -m  |grep ssh
[root@rocky ~]#

I used the below step .

dnf install libssh2-devel.x86_64
pecl search ssh2
pecl install -a ssh2-1.3.1
echo “” > /etc/php.d/40-ssh2.ini

I am using php 7.4

[root@rocky ~]# php -v
PHP 7.4.19 (cli) (built: May  4 2021 11:06:37) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.19, Copyright (c), by Zend Technologies
[root@rocky ~]#

Notice: on EL-9, php-pecl-ssh2 is available in the EPEL repository (but only for PHP 8.0).

1 Like

This is on Rocky 8.6.

Thanks. I ran this install successfully but php -m still does not report ssh2 being a module. Is there an additional step beyond creating the ini file?

which PHP version are you using ?
Did below command ran successfully or produced any error ?

pecl install -a ssh2-1.3.1

share the entire out of above command .

BTW, using alternative streams from my repository, ssh2 extension (and most of the existing extensions) are available without having to build from sources.

Hi remi,
how to use your repos as alternative streams ? Like we want to install everything from OS provided Application Stream ( Rocky Linux 8 - AppStream ) except the things which are not available there , then package/extension should be install from your repo.( like ssh2, redis, msgpack , igbinary, sodium etc )
Can this approach lead to packages conflicts ?

Our OS version is Rocky Linux 8.6 and PHP version is 7.4.19

Can this approach lead to packages conflicts ?

Should not

how to use your repos as alternative streams ?

Simply follow the Wizard instructions

Thanks for your prompt answer. Let me explore Wizard

Sorry, a Sept. deadline is fast approaching and I had to deal with it last week. I did not see any errors when installed and I no longer have the results of the install in the terminal history but when I run the command again:

pecl install -a ssh2-1.3.1
pecl/ssh2 is already installed and is the same as the released version 1.3.1

The PHP version is 7.4.19

Did you create the extension file by

echo “” > /etc/php.d/40-ssh2.ini
check if file exist by
cat /etc/php.d/40-ssh2.ini

if file exist either it should load the php extension ssh2 or should show some error.
check with
php -m