用 `fail2ban-client status` 查看 fail2ban 封禁情况
fail2ban 会默默运行几个月——当你突然无法从自己的 IP 登录 SSH 时,这条命令能告诉你是不是 jail 把你封了。
运行 `sudo fail2ban-client status sshd` 查看 SSH jail 的封禁计数以及当前被封禁的 IP 列表。
01命令
命令
$ sudo fail2ban-client status sshd02作用说明
不带参数的 `fail2ban-client status` 列出所有活动的 jail;加上 jail 名(通常是 sshd)则会显示过滤统计和「Banned IP list」。要解封误封的地址,执行 `sudo fail2ban-client set sshd unbanip 1.2.3.4`。另外两条易忘命令:`sudo fail2ban-client get sshd bantime` 查看封禁时长配置,`sudo fail2ban-client reload` 在不丢失封禁数据库的情况下重载配置。
03风险
!注意: 很容易把自己封掉:办公网络 NAT 出口的密码输错三次就可能封掉整个网络——怀疑 SSH 坏了之前先查这个列表。
04撤销
撤销
$ sudo fail2ban-client set sshd unbanip <IP>05来源
- fail2ban-client(1) — control fail2ban server from the command line依据: Documents `fail2ban-client status <JAIL>` which reports currently banned IPs, total bans, and retry statistics
最后验证: 2026-09-17 · 分类: 安全与隐私