Reputation: 21
While connect my destination server by
ssh2_connect("<<server-ip>>", 22)
then received error:
ssh2_connect(): error starting up ssh connection(-5): unable to exchange encryption keys
ssh2
extension and lib2ssh 1.8.0
already installed.
How to resolve this issue? Does any library need to be added or updated?
Upvotes: 2
Views: 615
Reputation: 1018
This problem is common when the versions are outdated or don't have matching encryption settings.
First remove the old version of libssh2 from this command:
sudo yum remove libssh2
Then, download and install the latest version:
wget https://www.libssh2.org/download/libssh2-1.10.0.tar.gz
tar -xvzf libssh2-1.10.0.tar.gz
cd libssh2-1.10.0
./configure
make
sudo make install
After installation, verify the version of libssh2
libssh2 -V
sudo yum install php-devel
Now, uninstall and reinstall the PHP ssh2 extension
pecl uninstall ssh2
pecl install ssh2
Restart your webserver( no sure which webserver you are using)
sudo systemctl restart httpd # For Apache
sudo systemctl restart php-fpm # For Nginx with PHP-FPM
If this update cannot fix your issue you have to update the key exchange algorithms on the server. So update me and I will help you out.
Upvotes: 2