Amazon AWS instance is set to log in with account password

The login method of Amazon AWS instances is key login, which is very inconvenient, so record the process of changing to account password login.

1. Link to log in to the instance
Log in to centos with the key, the following is the login setting centos of xshell

Remember to select centos when selecting the user when logging in, the root user 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 username and password to log in

a. First set a password for the root user
sudo passwd root

b. Switch to the root user
su root

c. Enter the following command to enable username and password login

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

d. Restart sshd to take effect
service sshd restart

Was this article helpful?

Related Articles

Leave A Comment?

You must be logged in to post a comment.