How to fix the SSH "no matching host key type found" error
-
The release of Ubuntu 22.04 LTS includes an update to OpenSSH which disabled support for shh-rsa algorithm. Attempting to ssh into Omega2 device from Ubuntu 22.04 system reports:
"Unable to negotiate with <insert Omega2 ip> port 22: no matching host key type found. Their offer: ssh-rsa"
The simple solution is to specify the algorithm on the ssh command line like so:
ssh -o HostKeyAlgorithms=ssh-rsa root@192.168.1.199
or
scp -o HostKeyAlgorithms=ssh-rsa <some file> root@192.168.1.199:/<some directory>
The algorithm can be re-enabled on Ubuntu 22.04 but is disabled by default due to a long-known compromise. Please refer to OpenSSH documentation for further information
-
@crispyoz it is also possible to re-enable it permanently only for your user in the Ubuntu system and your Onion, by editing or creating a file named "config" inside your ~/.ssh directory with something like:
Host onion HostKeyAlgorithms+=ssh-rsa
onion here is your Onion IP address or the name you use to ssh into it.
I use it a lot to be able to access old systems without having to type the options once and again.
It is also useful for reenabling KeyAlgorithms or setting per host options or user name, or ...
Use it with care and only when needed for a given host
-
@victoriano good information, thanks for posting. I kept my solution simple because of the controversy around enabling RSA.
-
Config file entry should be: