| 加固项 | SSH 认证方式 |
|---|---|
| 适用平台 | Linux(OpenSSH) |
| 风险等级 | 高 |
| 基线 | PasswordAuthentication no |
配置与生效
配置与生效
grep -Ei '^(PasswordAuthentication|PubkeyAuthentication|PermitRootLogin)' /etc/ssh/sshd_config
sed -i 's/^#\?PasswordAuthentication .*/PasswordAuthentication no/' /etc/ssh/sshd_config
sed -i 's/^#\?PubkeyAuthentication .*/PubkeyAuthentication yes/' /etc/ssh/sshd_config
sshd -t && systemctl reload sshd切换前确认所有人都有可用密钥并完成一次成功登录:直接关口令会让还没有密钥的人立刻被挡在门外。