Configure SSH key login
- Generate a key pair using the command
ssh-keygenor use an existing key pair - Copy the corresponding public key to the
root/.ssh/authorized_keysfile.
Disable password login
Edit the /etc/ssh/sshd_config file and modify the following parameters:
text
PubkeyAuthentication yes
PasswordAuthentication noRestart the SSH service
bash
sudo systemctl restart sshdIf it does not take effect, delete all files in etc/ssh/sshd_config.d .