Fixing PHP SSH2 extension
If you are having a problem with PHP segfaulting when using the PHP SSH2 extension, I will able to solve this issue by removing the system installed extension and using PECL to install it via source. There is problably is some sort of mismatch in the packaging between php-ssh2
and the dependency libssh2-1
.
Below is how I was able to fix it (all with sudo
):
apt remove php-ssh2
apt install libssh2-1-dev
vim /usr/share/php/Archive/Tar.php
remove&
from line 639 (see https://www.dotkernel.com/php-troubleshooting/fix-installing-pear-packages-with-php-7-2/)pecl install ssh2-1.1.2
pear install Archive_Tar
phpenmod ssh2
Related bugs and issues:
- https://stackoverflow.com/questions/41118475/segmentation-fault-on-fopen-using-sftp-and-ssh2
- https://core.trac.wordpress.org/ticket/42345
- https://bugs.php.net/bug.php?id=73597
- https://bugs.launchpad.net/ubuntu/+source/php-ssh2/+bug/1663281
- https://bugs.php.net/bug.php?id=74831
- https://bugs.launchpad.net/ubuntu/+source/php-ssh2/+bug/1712994
- https://pecl.php.net/package/ssh2
- https://www.php.net/manual/en/ssh2.installation.php