These are instructions on how to fix the 'no matching host key type found' error message when trying to SSH on Mac.
When attempting to SSH into an older server using macOS, you may receive a ssh error message that reads something like:
Unable to negotiate with 123.123.123.123 port 22: no matching host key type found. Their offer: ssh-rsa,ssh-dss
For a successful connection, OpenSSH must have at least one mutually-supported choice for each parameter. If the client and server fail to agree on a mutual set of parameters then the connection will fail. In this case, the client and server were unable to agree on the host key algorithm type. The server offered ssh-rsa or ssh-dss which are supported by OpenSSH but no longer enabled by default due to security concerns.
The ssh-rsa signature scheme has been deprecated since OpenSSH 8.8 which was released on 2021-08-20.
In the SSH protocol, the "ssh-rsa" signature scheme uses the SHA-1 hash algorithm in conjunction with the RSA public key algorithm. It is now possible to perform chosen-prefix attacks against the SHA-1 algorithm for less than USD$50K.
If you have control of the server, you should upgrade your OpenSSH version; however, if you need immediate access to the server, there are a couple ways to resolve this...
Reattempt your SSH connection, adding the following to your command line:
-oHostKeyAlgorithms=+ssh-rsa
ie. ssh -oHostKeyAlgorithms=+ssh-rsa username@123.123.123.123
Alternatively, you can follow these steps to make the option permanent...
Open a new Terminal window.
Type sudo nano ~/.ssh/config, then enter your administrative password if prompted.
Add the following lines to the config file, replacing 123.123.123.123 with the IP of the server you are connecting to.
Host 123.123.123.123
HostKeyAlgorithms +ssh-rsa
Press Control+X to exit. Input Y when asked to ask save modified buffer.
Hit Return to confirm the file name to write.
Now you can SSH into your server as normal.
ssh username@123.123.123.123
If after fixing the 'no matching host key type found' error message, you get a 'no matching key exchange method' error, follow these steps:
● How to Fix 'No Matching Key Exchange Method Found' on Mac
When attempting to SSH into an older server using macOS, you may receive a ssh error message that reads something like:
Unable to negotiate with 123.123.123.123 port 22: no matching host key type found. Their offer: ssh-rsa,ssh-dss
For a successful connection, OpenSSH must have at least one mutually-supported choice for each parameter. If the client and server fail to agree on a mutual set of parameters then the connection will fail. In this case, the client and server were unable to agree on the host key algorithm type. The server offered ssh-rsa or ssh-dss which are supported by OpenSSH but no longer enabled by default due to security concerns.
The ssh-rsa signature scheme has been deprecated since OpenSSH 8.8 which was released on 2021-08-20.
In the SSH protocol, the "ssh-rsa" signature scheme uses the SHA-1 hash algorithm in conjunction with the RSA public key algorithm. It is now possible to perform chosen-prefix attacks against the SHA-1 algorithm for less than USD$50K.
If you have control of the server, you should upgrade your OpenSSH version; however, if you need immediate access to the server, there are a couple ways to resolve this...
EASIEST SOLUTION
Step One
Reattempt your SSH connection, adding the following to your command line:
-oHostKeyAlgorithms=+ssh-rsa
ie. ssh -oHostKeyAlgorithms=+ssh-rsa username@123.123.123.123
Alternatively, you can follow these steps to make the option permanent...
PERMANENT SOLUTION
Step One
Open a new Terminal window.
Step Two
Type sudo nano ~/.ssh/config, then enter your administrative password if prompted.
Step Three
Add the following lines to the config file, replacing 123.123.123.123 with the IP of the server you are connecting to.
Host 123.123.123.123
HostKeyAlgorithms +ssh-rsa
Step Four
Press Control+X to exit. Input Y when asked to ask save modified buffer.
Hit Return to confirm the file name to write.
Step Five
Now you can SSH into your server as normal.
ssh username@123.123.123.123
IMPORTANT NOTES
If after fixing the 'no matching host key type found' error message, you get a 'no matching key exchange method' error, follow these steps:
● How to Fix 'No Matching Key Exchange Method Found' on Mac