The login method of Amazon AWS instance is the key login, which I personally feel very inconvenient and not used to, so I will record the login process of modifying the account password.

1. Log in to the instance

Use the key to log in to CentOS. The following is the login Settings of Xshell

When logging in, select centos as user. Root cannot log in.

WARNING! The remote SSH server rejected X11 forwarding request.
Please login as the user "centos" rather than the user "root".

2. Set user name and password to log in

1. Set the password for root first

sudo passwd root

2. Switch to root

su root

3. Enter the following command to login with user name and password

sed -ri 's/^#? (PasswordAuthentication)\s+(yes|no)/\1 yes/' /etc/ssh/sshd_config sed -ri 's/^#? (PermitRootLogin)\s+(yes|no)/\1 yes/' /etc/ssh/sshd_config sed -ri 's/^/#/; s/sleep 10"\s+/&\n/' /root/.ssh/authorized_keys

4. Restart SSHD to take effect

service sshd restart