密码再复杂也怕撞库与字典。禁密码、只认密钥、禁 root 直登,是 SSH 加固三连。
防护配置
# /etc/ssh/sshd_config
PasswordAuthentication no
PubkeyAuthentication yes
PermitRootLogin no
systemctl reload sshd
要点速览
- PubkeyAuthentication yes 只接受密钥。
- PasswordAuthentication no 关掉密码通道。
- PermitRootLogin no 逼着先普通用户再提权。
SSH 加固三连:禁密码、只密钥、封 root 直登。