加固要点(sshd_config)
加固要点(sshd_config)
PermitRootLogin no
PasswordAuthentication no # 全面转向密钥认证
PubkeyAuthentication yes
MaxAuthTries 3
LoginGraceTime 30
AllowUsers deploy ops
# 配合 fail2ban 或防火墙限速封禁高频失败来源失败登录观察
失败登录观察
grep 'Failed password' /var/log/auth.log | tail -20
# 或 journalctl -u sshd --since '1 hour ago' | grep Failed
lastb | head # 查看失败登录记录切到密钥认证前先确保密钥可用并为关键设备保留带外访问方式,避免自锁。