When CentOS uses the key to log in to the server, the password fails

question

Configure various settings for key login on the target server;
use ssh to log in on the local machine.
A password exception occurred;
it was found that the user password was prompted instead of the key password.

solution:

centos opens Selinux by default; you need to manually close the program.
Use:
/usr/sbin/setenforce 0 Immediately close SELINUX
Second:
Use a text editor to open /etc/selinux/config
and comment out SELINUX=enforcing: #SELINUX=enforcing, then add a new line: SELINUX=disabled Exit and save.
Restart the sshd service.

It may be that the enablement of selinux causes the sshd login to fail to use key authentication.

Guess you like

Origin blog.csdn.net/codemanship/article/details/46733099