Xshell logs in to AWS EC2 "The selected user key is not registered on the remote host" error solution

How to solve "The selected user key is not registered on the remote host"

In usetelnetWhen connecting to the , you will encounter the "". Basically every novice will encounter the same error, so what exactly causes the "The selected user key is not registered on the remote host" error when connecting to ? The secret key is not registered on the remote host" error? The reasons for the error are analyzed in detail below.

Xshell login to AWS "The selected user key is not registered on the remote host" error solution-1

The tool is one of the more popular SSH remote tools. Compared with putty, it is more powerful and supports openssh.

After creating the server, use SSH to connect, and you will encounter an SSH security warning when connecting.

Please verify the host key.

The host key of xxx is inconsistent with the one saved in the local host key database. The host key has been changed or someone is trying to listen in on this connection. If you are unsure, it is recommended to cancel this connection.

Xshell login to AWS "The selected user key is not registered on the remote host" error solution-1

I'm a little confused at this point. Is it a problem with the key generated by , or is it caused by using Xshell for SSH connection? The next step is to find out where the error is.

Step 1: First check whether the user name is wrong. AWS has a small pitfall, that is, the default user name is different for each type of server, unlike That is the default root, let's take a look at the usernames of various instances of AWS.

What is the default username for EC2 Linux instances (used for SSH, PuTTY, etc.)

EC2/Default username on Linux instances (, Debian, Fedora, Amazon Linux, etc.)

  • Amazon Linux 2023/Amazon Linux 2/Amazon Linux  ec2-user
  • centos or ec2-user
  • Debian admin
  • Fedora fedora or ec2-user
  • ec2-user or root
  • SUSE ec2-user or root
  • Ubuntu ubuntu
  • ec2-user
  • Bitnami bitnami

The default user name of the RHEL system installed on the test machine is ec2-user or root. When connecting remotely, I tried both user names and still could not connect.

AWS official help page:https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/connect-to-linux-instance.html

Step 2: After confirming that it is not a problem with the user name, then check to see if there is a problem with the key.

Instructions for using keys for remote connections are given in the official documentation.

You must know the location of the private key file to connect to your instance. For SSH connections, you must set permissions so that only you can read the file.

For information about how key pairs work when using Amazon EC2, see Amazon EC2 Key Pairs and Linux Instances.

find the private key

.pem Gets the fully qualified path to the location on your computer of the file for the key pair you specified when you launched the instance. For more information, see Identifying the public key specified at startup. If you can't find the private key file, see I lost my private key. How do I connect to my Linux instance?

If you are using Putty to connect to the instance and need to convert the file .pem to .ppk, please refer to this sectionConvert private keys using PuTTYgen in the topic Connecting to a Linux instance from Windows using PuTTY.

Set the permissions on your private key so that only you can read it

from or Linux connection

If you plan to use an SSH client on a or Linux machine to connect to a Linux instance, use the following command to set the permissions on the private key file so that only you can read it.

chmod 400 key-pair-name.pem
If you don't set these permissions, you can't use this key pair to connect to your instance. For more information, see Error: Private key file is not protected.

from connect

Open File Explorer and right-click on the .pem file. Select Properties > Security tab, and then select Advanced. Choose to disable inheritance. Removes access from all users except the current user.

Try modifying the properties of the private key when making a remote connection in Windows.

Xshell login to AWS "The selected user key is not registered on the remote host" error solution-1

After modifying the properties, I still cannot connect using the key.

Step 3: Is the version of Xshell 6, the SSH remote connection tool, too low, preventing SSH connection?

Because Xshell 6 has been used to manage the server on the computer before, Xshell has not been updated for a long time. Next, update Xshell 6 to and try to connect again.

Xshell login to AWS EC2 "The selected user key is not registered on the remote host" error solution-1

connection succeeded!

Xshell login to AWS EC2 "The selected user key is not registered on the remote host" error solution-1

After a lot of fussing, it turned out to be a problem with the Xshell version being too low.

Finally, to summarize, if you cannot connect to the server when connecting to AWS EC2 remotely, the most likely reason is that you did not enter the user name correctly. For example, root is entered by default.

Another reason is that the software version of SSH is too low. Upgrade Xshell!

If you don't have a free For AWS EC2, you can register for free.

Free application for 12 months AWS Amazon cloud server amazon cloud Amazon cloud latest tutorial

AWS China official website: https://aws.amazon.com/cn/
Official website: https://www.amazonaws.cn/

uzbox
uzbox

Leave a Reply

Your email address will not be published. Required fields are marked *