fail2ban
БесплатноБез исполняемых скриптовНе проверенProtect servers from brute force attacks with Fail2Ban. Use when a user asks to block repeated failed login attempts, protect SSH, secure web servers from…
от TerminalSkills★ 221 звезда на GitHubОб этом скилле
Fail2Ban
Overview
Fail2Ban (1.1.1, August 2026, is the latest release) monitors log files or the systemd journal for failed authentication attempts and bans offending IPs through the firewall (nftables or iptables). Protects SSH, Nginx, Apache, Postfix, and any service with log-based authentication.
Instructions
Step 1: Install
sudo apt install fail2ban
sudo systemctl enable --now fail2ban
sudo fail2ban-client -V # confirm version
On Debian and Ubuntu the distribution package ships an enabled sshd jail that reads the systemd journal (upstream paths-debian.conf sets sshd_backend = systemd and, since 1.1.1, banaction = nftables; check fail2ban-client get sshd actions on your host). Elsewhere the upstream default banaction is iptables-multiport, and bantime/findtime default to 10m with maxretry = 5.
Step 2: Configure
# /etc/fail2ban/jail.local — Custom configuration (never edit jail.conf)
[DEFAULT]
bantime = 1h
findtime = 10m
maxretry = 5
# match your firewall: nftables, or iptables-multiport on older hosts
banaction = nftables
# your own office or VPN address, so you cannot lock yourself out
ignoreip = 127.0.0.1/8 ::1 203.0.113.10
[sshd]
enabled = true
port = ssh
maxretry = 3
bantime = 24h
[nginx-http-auth]
enabled = true
port = http,https
maxretry = 5
[nginx-botsearch]
enabled = true
port = http,https
maxretry = 2
bantime = 7d
After editing, check and apply: sudo fail2ban-client -t (config test), then sudo fail2ban-client reload.
Step 3: Monitor
sudo fail2ban-client status # list active jails
sudo fail2ban-client status sshd # show banned IPs
sudo fail2ban-client set sshd unbanip 198.51.100.23 # unban
sudo fail2ban-client set sshd banip 198.51.100.77 # manual ban
sudo fail2ban-client unban --all # lift every ban
Examples
Example 1: "Stop people hammering SSH on my VPS"
Add the [sshd] block above to /etc/fail2ban/jail.local with maxretry = 3, run sudo fail2ban-client reload, then sudo fail2ban-client status sshd. Result: Currently banned and Banned IP list appear in the output, and an address that fails three logins within findtime is banned for bantime.
Example 2: "Test a custom filter before enabling the jail"
Run fail2ban-regex /var/log/nginx/error.log /etc/fail2ban/filter.d/nginx-botsearch.conf. Result: a summary such as Lines: 18450 lines, 0 ignored, 212 matched, 18238 missed shows whether the regex catches what you expect; only then set enabled = true for the jail.
Guidelines
- Always create jail.local — jail.conf gets overwritten on updates.
- Start conservative: 5 retries, 1h ban. Adjust based on logs.
- For modern alternative with community threat sharing, consider CrowdSec.
- Use
fail2ban-regexto test custom filters before deploying. - Add your own addresses to
ignoreip; a forgotten-password loop from your office IP will otherwise ban you. - Bans only work if the log path or journal the filter reads actually contains the failures (
backend = systemdwhen there is no/var/log/auth.log). - Fail2Ban reacts after the fact; it does not replace key-only SSH (
PasswordAuthentication no).
Установить fail2ban в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл fail2ban?
Protect servers from brute force attacks with Fail2Ban. Use when a user asks to block repeated failed login attempts, protect SSH, secure web servers from brute force, or ban malicious IPs automatically.
Как установить скилл fail2ban?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл fail2ban запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic