foreword
The tutorials on the Internet are not uniform. I didn’t pay attention to it before. I didn’t find out that some online teaching methods are wrong until today, so record the correct method.
1. Modify the configuration file
(1) Modify ssh_config
vim /etc/ssh/ssh_config
Remove the # in front of PubkeyAuthentication yes
(2) Modify sshd_config
vim /etc/ssh/sshd_config
Remove the # in front of #PermitRootLogin prohibit-password
and change the following prohibit-password to yes
Remove the # in front of PubkeyAuthentication yes
Restart the ssh service
service ssh restart
The ssh service starts automatically at boot
systemctl restart ssh