How to Disable Password Login in CentOS7
One option is the following: In CentOS7, you can disable password login by modifying the SSH configuration file. Here are the specific steps:
- Login to the system with the root user.
- Open the SSH configuration file /etc/ssh/sshd_config using vim or another text editor.
sudo vim /etc/ssh/sshd_config
- Locate the following two lines of code within the file:
#PasswordAuthentication yes
#PermitRootLogin yes
Change these two lines of code to:
PasswordAuthentication no
PermitRootLogin no
- Save the file and exit the editor.
- Restart the SSH service to apply the configuration changes.
sudo systemctl restart sshd
Password login has been disabled, so you can only use SSH keys to authenticate when logging into the CentOS7 system.