# PHP SSH2 install

**URL:** <https://forums.rockylinux.org/t/php-ssh2-install/6923>\
**Category:** Rocky Linux Help & Support\
**Created:** [August 12, 2022, 2:58pm UTC](https://forums.rockylinux.org/t/php-ssh2-install/6923 "2022-08-12T14:58:11Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![wesmat](https://avatars.discourse-cdn.com/v4/letter/w/c77e96/32.png) [@wesmat](https://forums.rockylinux.org/u/wesmat)\
**Post date:** [August 12, 2022, 2:58pm UTC](https://forums.rockylinux.org/t/php-ssh2-install/6923/1 "2022-08-12T14:58:11Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![felfert](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.rockylinux.org/felfert/32/2259_2.png) [@felfert](https://forums.rockylinux.org/u/felfert)\
**Post date:** [August 12, 2022, 4:38pm UTC](https://forums.rockylinux.org/t/php-ssh2-install/6923/2 "2022-08-12T16:38:41Z")

</div>

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: [https://www.libssh2.org/](https://www.libssh2.org/)

---

<div class="post-metadata">

**Author:** ![wesmat](https://avatars.discourse-cdn.com/v4/letter/w/c77e96/32.png) [@wesmat](https://forums.rockylinux.org/u/wesmat)\
**Post date:** [August 12, 2022, 4:53pm UTC](https://forums.rockylinux.org/t/php-ssh2-install/6923/3 "2022-08-12T16:53:40Z")

</div>

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.”

---

<div class="post-metadata">

**Author:** ![felfert](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.rockylinux.org/felfert/32/2259_2.png) [@felfert](https://forums.rockylinux.org/u/felfert)\
**Post date:** [August 12, 2022, 5:13pm UTC](https://forums.rockylinux.org/t/php-ssh2-install/6923/4 "2022-08-12T17:13:18Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![wesmat](https://avatars.discourse-cdn.com/v4/letter/w/c77e96/32.png) [@wesmat](https://forums.rockylinux.org/u/wesmat)\
**Post date:** [August 12, 2022, 5:29pm UTC](https://forums.rockylinux.org/t/php-ssh2-install/6923/5 "2022-08-12T17:29:13Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![felfert](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.rockylinux.org/felfert/32/2259_2.png) [@felfert](https://forums.rockylinux.org/u/felfert)\
**Post date:** [August 12, 2022, 5:45pm UTC](https://forums.rockylinux.org/t/php-ssh2-install/6923/6 "2022-08-12T17:45:40Z")

</div>

On rocky8 or rocky9?

---

<div class="post-metadata">

**Author:** ![linuxlover](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.rockylinux.org/linuxlover/32/2227_2.png) [@linuxlover](https://forums.rockylinux.org/u/linuxlover)\
**Post date:** [August 12, 2022, 5:59pm UTC](https://forums.rockylinux.org/t/php-ssh2-install/6923/7 "2022-08-12T17:59:15Z")

</div>

> [@wesmat](#):
>
> dnf install libssh2-devel.x86\_64

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

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

```

I used the below step .

dnf install libssh2-devel.x86\_64  
pecl search ssh2  
pecl install -a ssh2-1.3.1  
echo “extension=ssh2.so” \> /etc/php.d/40-ssh2.ini

I am using php 7.4

```auto
[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 ~]#

```

---

<div class="post-metadata">

**Author:** ![remi](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.rockylinux.org/remi/32/1425_2.png) [@remi](https://forums.rockylinux.org/u/remi)\
**Post date:** [August 13, 2022, 5:48am UTC](https://forums.rockylinux.org/t/php-ssh2-install/6923/8 "2022-08-13T05:48:21Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![wesmat](https://avatars.discourse-cdn.com/v4/letter/w/c77e96/32.png) [@wesmat](https://forums.rockylinux.org/u/wesmat)\
**Post date:** [August 15, 2022, 4:09pm UTC](https://forums.rockylinux.org/t/php-ssh2-install/6923/9 "2022-08-15T16:09:43Z")

</div>

This is on Rocky 8.6.

---

<div class="post-metadata">

**Author:** ![wesmat](https://avatars.discourse-cdn.com/v4/letter/w/c77e96/32.png) [@wesmat](https://forums.rockylinux.org/u/wesmat)\
**Post date:** [August 15, 2022, 4:19pm UTC](https://forums.rockylinux.org/t/php-ssh2-install/6923/10 "2022-08-15T16:19:48Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![linuxlover](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.rockylinux.org/linuxlover/32/2227_2.png) [@linuxlover](https://forums.rockylinux.org/u/linuxlover)\
**Post date:** [August 15, 2022, 5:23pm UTC](https://forums.rockylinux.org/t/php-ssh2-install/6923/11 "2022-08-15T17:23:27Z")

</div>

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 .

---

<div class="post-metadata">

**Author:** ![remi](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.rockylinux.org/remi/32/1425_2.png) [@remi](https://forums.rockylinux.org/u/remi)\
**Post date:** [August 16, 2022, 9:17am UTC](https://forums.rockylinux.org/t/php-ssh2-install/6923/12 "2022-08-16T09:17:04Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![linuxlover](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.rockylinux.org/linuxlover/32/2227_2.png) [@linuxlover](https://forums.rockylinux.org/u/linuxlover)\
**Post date:** [August 16, 2022, 10:25am UTC](https://forums.rockylinux.org/t/php-ssh2-install/6923/13 "2022-08-16T10:25:55Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![remi](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.rockylinux.org/remi/32/1425_2.png) [@remi](https://forums.rockylinux.org/u/remi)\
**Post date:** [August 16, 2022, 10:28am UTC](https://forums.rockylinux.org/t/php-ssh2-install/6923/14 "2022-08-16T10:28:42Z")

</div>

> Can this approach lead to packages conflicts ?

Should not

> how to use your repos as alternative streams ?

Simply follow the [Wizard instructions](https://rpms.remirepo.net/wizard/)

---

<div class="post-metadata">

**Author:** ![linuxlover](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.rockylinux.org/linuxlover/32/2227_2.png) [@linuxlover](https://forums.rockylinux.org/u/linuxlover)\
**Post date:** [August 16, 2022, 10:31am UTC](https://forums.rockylinux.org/t/php-ssh2-install/6923/15 "2022-08-16T10:31:46Z")

</div>

Thanks for your prompt answer. Let me explore Wizard

---

<div class="post-metadata">

**Author:** ![wesmat](https://avatars.discourse-cdn.com/v4/letter/w/c77e96/32.png) [@wesmat](https://forums.rockylinux.org/u/wesmat)\
**Post date:** [August 21, 2022, 11:28pm UTC](https://forums.rockylinux.org/t/php-ssh2-install/6923/16 "2022-08-21T23:28:02Z")

</div>

> [@linuxlover](#):
>
> pecl install -a ssh2-1.3.1

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

---

<div class="post-metadata">

**Author:** ![linuxlover](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.rockylinux.org/linuxlover/32/2227_2.png) [@linuxlover](https://forums.rockylinux.org/u/linuxlover)\
**Post date:** [August 22, 2022, 7:48pm UTC](https://forums.rockylinux.org/t/php-ssh2-install/6923/17 "2022-08-22T19:48:16Z")

</div>

Did you create the extension file by

echo “extension=ssh2.so” \> /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

---

<div class="post-metadata">

**Author:** ![label](https://avatars.discourse-cdn.com/v4/letter/l/c5a1d2/32.png) [@label](https://forums.rockylinux.org/u/label)\
**Post date:** [August 24, 2023, 4:53am UTC](https://forums.rockylinux.org/t/php-ssh2-install/6923/18 "2023-08-24T04:53:36Z")

</div>

Closed on August 24, 2023, 4:53am UTC


