Unable to get SFTP working in PHP script

I need to code a PHP script to do SFTP which requires SSH2 support in PHP. I have libssh2-1 installed but when I try to use the ssh2_connect function I get an error message saying ‘undefined function ssh2_connect()’. There are various things I can find about a package called php-ssh2 but nothing seems to exist for openSUSE TW. Does anyone have any ideas as to how I get this working please? I need a fairly vanilla method as this will have to port to a PHP installation on Windows as well and needs to be fairly straight forward.


AFAIK this is not part of php itself. Found this page, http://php.net/manual/en/ssh2.installation.php AFAICS the instructions for Centos should work.

AFAICS, for the case of openSUSE, the SSH2 libraries for PHP5 are in these repositories: <https://download.opensuse.org/repositories/server:/php:/extensions/>.

The OP is on Tw, which has php7.

The issue with the CENTOS instructions is that they dont come up with a downloadable package. I guess I have to work it out myself for a PHP7.4 package.


A possible Tumbleweed disadvantage?

Well I managed to download the required package and install it and now it works.


Yay, awesome. Thanks for reporting back…

If you have ssh access on your server, you can use PHPseclib to connect to sftp in PHP. PHPseclib is a PHP sftp library that can use to easily create sftp connection and upload and download files from ftp.