ssh 启用密钥认证并禁用密码认证

2 weeks ago
0 comment

在远程服务器上设置公钥:

nano ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys

禁用密码登录:

sudo nano /etc/ssh/sshd_config

找到并修改以下参数:

PasswordAuthentication no
ChallengeResponseAuthentication no
UsePAM no

重启 ssh 服务:

sudo systemctl restart sshd