php 7.4, ssh_connect(), "Unable to exchange encryption keys" when connecting to ubuntu 22.04 machines

Viewed 14

When using ssh2_connect

ssh2_connect($this->host, $this->sshPort)

to connect to a server running Ubuntu 22.04 I get the following error on the client

PHP Warning:  ssh2_connect(): Error starting up SSH connection(-5): Unable to exchange encryption keys in /root/ssh.php on line 175
PHP Warning:  ssh2_connect(): Unable to connect to xxx.xxx.com in /root/ssh.php on line 175

I get the following error in the Server auth.log

Unable to negotiate with xx.xx.xx.xx port 45574: no matching host key type found. Their offer: ssh-rsa,ssh-dss [preauth]

I found another thread here That asked me to do this, along with other things. No luck at all

ssh2_connect($this->host, $this->sshPort , [ 'hostkey' => 'ecdsa-sha2-nistp256,ssh-rsa'])

I get same error on the client and the following error on the server

Unable to negotiate with xx.xx.xx.xx port 53942: no matching host key type found. Their offer: ssh-rsa [preauth]

It looks like ssh2_connect only allows ssh-rsa and ssh-dss.

Has anyone got a solution to allow ssh2_connect to connect to a ubuntu server running 22.04

Cheers

0 Answers
Related