Problems Installing PHP SSH2 in order to use SFTP functions
I need to be able to write a script which connects to an SFTP server to retrieve a file.
My searching led me to the conclusion that I need the PHP SSH2 extension installed on my server to make this work.
I'm following the guide here:
= 4.0.0, version <= 6.0.0), installed version is 7.3.30
No valid packages found
I am running Multi-PHP, and would like to install this extension on all versions that I have running - Can anyone help me with where to go next?
Thanks
-
Hey there! The output of the message indicates the problem - that specific pecl package is only available for PHP versions higher than 4 and lower than 6, which would mean you'd need to be using PHP 5.6 or older on cPanel in order to get that installed. The package is not available for newer versions of PHP, so it would be best to find a different piece of software that supports more modern installations. 0 -
Thanks for your reply. I guess that was my question - if this is not the way to get sftp connections to work in the latest versions of PHP, what is? Thanks 0 -
I see this has to be installed manually as a modern version isn't included from pecl directly. You can run this command to perform that work, just modifying the php## to work with your particular version. For example, this works with PHP 7.4: /opt/cpanel/ea-php70/root/usr/bin/pecl install https://pecl.php.net/get/ssh2-1.2.tgz
Can you try that and let me know if that works?0 -
Thank you, that worked and it installed successfully. However, when attempting to use the ssh2_connect function, I receive the following error: Error starting up SSH connection(-5): Unable to exchange encryption keys 0 -
Well, we made some progress at least! For how to use the function, that part I can't be of much assistance with. I'm assuming you have libssh2.1.8 or higher on your system, correct? If so, I'd expect things to work well. There were some older bug reports on this (PHP :: Bug #57062 :: Error starting up SSH connection(-5): Unable to exchange encryption keys) but I don't see anything recent about this exact issue. 0 -
Forgive me, I don't know how to check or update libssh, is there a command to do this? Thanks 0 -
Sure thing - you can run this on the command line through SSH or through the WHM >> Terminal: rpm -qa | grep libssh
If you have automatic updates enabled on the system, it's likely you already have the latest available.0
Please sign in to leave a comment.
Comments
7 comments