Home > Back-end >  Call to undefined function ssh2_connect() after PHP 8.1.14 update
Call to undefined function ssh2_connect() after PHP 8.1.14 update

Time:01-11

After updating PHP 8.1 on Jan 7 2023 we began seeing "Call to undefined function ssh2_connect()" in previously working scripts. The Jan 5 PHP release changelog does not mention SSH at all. Apache2 has been manually restarted and eventually a full reboot was done.

We are running PHP 8.1.14 (cli) (built: Jan 7 2023 08:34:41) (NTS) under Debian GNU/Linux 10 (buster).

In phpinfo() output I see libSSH Version libssh2/1.8.0 with /etc/php/8.1/apache2/php.ini as primary ini loaded. There is not however any SSH extension explicitly enabled in that file and phpinfo() only lists libSSH and no larger SSH config table is shown.

Additional INI files parsed do not reference SSH in their names

/etc/php/8.1/apache2/conf.d/10-mysqlnd.ini, /etc/php/8.1/apache2/conf.d/10-opcache.ini, /etc/php/8.1/apache2/conf.d/10-pdo.ini, /etc/php/8.1/apache2/conf.d/15-xml.ini, /etc/php/8.1/apache2/conf.d/20-bcmath.ini, /etc/php/8.1/apache2/conf.d/20-bz2.ini, /etc/php/8.1/apache2/conf.d/20-calendar.ini, /etc/php/8.1/apache2/conf.d/20-ctype.ini, /etc/php/8.1/apache2/conf.d/20-curl.ini, /etc/php/8.1/apache2/conf.d/20-dom.ini, /etc/php/8.1/apache2/conf.d/20-exif.ini, /etc/php/8.1/apache2/conf.d/20-ffi.ini, /etc/php/8.1/apache2/conf.d/20-fileinfo.ini, /etc/php/8.1/apache2/conf.d/20-ftp.ini, /etc/php/8.1/apache2/conf.d/20-gd.ini, /etc/php/8.1/apache2/conf.d/20-gettext.ini, /etc/php/8.1/apache2/conf.d/20-iconv.ini, /etc/php/8.1/apache2/conf.d/20-intl.ini, /etc/php/8.1/apache2/conf.d/20-mbstring.ini, /etc/php/8.1/apache2/conf.d/20-mysqli.ini, /etc/php/8.1/apache2/conf.d/20-pdo_mysql.ini, /etc/php/8.1/apache2/conf.d/20-phar.ini, /etc/php/8.1/apache2/conf.d/20-posix.ini, /etc/php/8.1/apache2/conf.d/20-readline.ini, /etc/php/8.1/apache2/conf.d/20-shmop.ini, /etc/php/8.1/apache2/conf.d/20-simplexml.ini, /etc/php/8.1/apache2/conf.d/20-soap.ini, /etc/php/8.1/apache2/conf.d/20-sockets.ini, /etc/php/8.1/apache2/conf.d/20-sysvmsg.ini, /etc/php/8.1/apache2/conf.d/20-sysvsem.ini, /etc/php/8.1/apache2/conf.d/20-sysvshm.ini, /etc/php/8.1/apache2/conf.d/20-tokenizer.ini, /etc/php/8.1/apache2/conf.d/20-xmlreader.ini, /etc/php/8.1/apache2/conf.d/20-xmlwriter.ini, /etc/php/8.1/apache2/conf.d/20-xsl.ini, /etc/php/8.1/apache2/conf.d/20-zip.ini

Issuing sudo apt install php-ssh2 gets php-ssh2 is already the newest version (1.3.1 0.13-7 0~20221209.25 debian10~1.gbp33475c).

Additionally sudo apt remove php-ssh2 and sudo apt install php-ssh2 were issued along with sudo service apache2 restart but this did not change the " Call to undefined function ssh2_connect()" error.

Do I need to add a line explicitly enabling ssh2 in the primary ini? How best to further chase the error?

CodePudding user response:

I don't know how installing php specific modules work without specifying a version number, but to be sure you get the module you want for your specific PHP-version add the version after php. In your case it would be php8.1

So to install ssh2 for PHP 8.1 with apt you would use apt install php8.1-ssh2.

If you're using FPM running PHP you need to make sure you reload it after installing a new module (service php8.1-fpm reload).

  • Related