How do I resolve the "Unable to negotiate: No matching host key type found" error when connecting to my EC2 Linux instance using SSH?
I receive the error "No matching host key type found" or "No matching key exchange method found" when connecting to my Amazon Elastic Compute Cloud (Amazon EC2) Linux instance using SSH.  Short description
"I receive the error "No matching host key type found" or "No matching key exchange method found" when connecting to my Amazon Elastic Compute Cloud (Amazon EC2) Linux instance using SSH.  Short descriptionShort descriptionYou might see one of the following errors when connecting to an EC2 Linux instance using SSH:No matching host key type found: This error occurs If SSH can't negotiate a common encryption algorithm or host key with the server that you're connecting to.No matching key exchange method found: This error indicates a problem with the key exchange algorithm negotiated between the SSH client and server during the SSH handshake. This error occurs when the SSH client and server have different or incompatible key exchange algorithms.ResolutionUpdate the openssh-clientOlder versions of the openssh-client might not support the key exchange algorithm negotiated by the server. Run one of the following commands to update the client to the latest version:Ubuntu and Debiansudo apt upgrade openssh-clientAmazon Linux, RHEL, and Fedorasudo yum upgrade openssh-clientsResolve the "no matching host key type found" errorExample errorUnable to negotiate with X.X.X.X port 22. no matching host key type found. Their offer: rsa-sha2-512,rsa-sha2-256,ecdsa-sha2-nistp256,ssh-ed25519.To resolve this error, make sure that the server and client have at least a single matching host key algorithm. Run the following command on the server and the client to check the host key algorithm:sudo ssh -Q keyTo add additional algorithms in the client, append the following line in the ~/.ssh/config or /etc/ssh/ssh_config file:vi ~/.ssh/configHostkeyAlgorithms +ssh-ed25519Resolve the "no matching key exchange method found" errorExample error Unable to negotiate with X.X.X.X port 22: no matching key exchange method found. Their offer: curve25519-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha25To resolve this error, make sure that the server and client having at least a single matching key exchange algorithm. Run the following command on the server and the client to check the key exchange algorithm:sudo ssh -Q kexTo add additional key exchange algorithm on the client, append the following line in the ~/.ssh/config or /etc/ssh/ssh_config file:vi ~/.ssh/configKexAlgorithms +diffie-hellman-group16-sha512Related informationOpenSSH Legacy Options on openssh.comFollow"