Quick answer
How to install fail2ban?
To install fail2ban, run apt install fail2ban, write /etc/fail2ban/jail.local with the sshd jail enabled, set backend = systemd on Debian 13, restart the service and check it with fail2ban-client status sshd. On an IronKVM VPS it takes 6 steps; the defaults ban an address after 5 failures in 10 minutes.
In brief
- fail2ban scans logs and bans addresses with too many failed logins, through firewall rules.
- Never edit jail.conf: put your settings in jail.local or jail.d.
- Defaults in jail.conf: bantime 10 minutes, findtime 10 minutes, maxretry 5.
- No jail is on by default: enable sshd yourself.
- The systemd backend reads the journal and needs the systemd Python library.
Which fail2ban settings matter?
| Setting | Default | This guide | Meaning |
|---|---|---|---|
| bantime | 10m | 1h | How long an address stays banned |
| findtime | 10m | 10m | Window in which failures are counted |
| maxretry | 5 | 5 | Failures that trigger a ban |
| backend | auto | systemd | Where log lines are read |
| enabled | false | true for sshd | Whether the jail runs |
| ignoreip | not set | your fixed IP | Addresses never banned |
What are the steps to install fail2ban?
Install the packages
Install fail2ban and python3-systemd so the systemd backend can read the journal.
Create jail.local
Write your settings in /etc/fail2ban/jail.local. jail.conf may be replaced by package updates.
Enable the sshd jail
Set enabled = true and backend = systemd under [sshd].
Whitelist your own address
Add your fixed IP to ignoreip if you have one, so a typo never bans you.
Start the service
Enable fail2ban at boot and restart it to load the file.
Check the jail
Run fail2ban-client status sshd to see failures and banned addresses.
sudo apt install fail2ban python3-systemd
sudo tee /etc/fail2ban/jail.local <<'EOF'
[DEFAULT]
bantime = 1h
findtime = 10m
maxretry = 5
ignoreip = 127.0.0.1/8 ::1
[sshd]
enabled = true
backend = systemd
EOF
sudo systemctl enable fail2ban
sudo systemctl restart fail2bansudo fail2ban-client ping
sudo fail2ban-client status
sudo fail2ban-client status sshd
sudo fail2ban-client set sshd unbanip 203.0.113.5Why use jail.local instead of editing jail.conf?
Because package updates can overwrite jail.conf, while jail.local is never touched. The header of jail.conf says not to modify it and to put changes in jail.local or a file in jail.d. The Debian manual page adds that .conf files should stay unchanged to ease upgrades.
Settings in jail.local override the same keys in jail.conf. You only write what you change. The [DEFAULT] section applies to every jail; a value under [sshd] applies to that jail only.
Why set backend = systemd on Debian 13?
Because the SSH server logs to the systemd journal, and this backend reads the journal directly. The fail2ban manual says the systemd backend uses the systemd Python library to access the journal, and that logpath is not valid with it. The jail’s filter selects the right journal entries instead.
The default backend is auto, which tries pyinotify, then systemd, then polling. Setting systemd explicitly removes the guesswork. If fail2ban-client status sshd shows a file list and zero failures after a bad login, check the backend first.
Is fail2ban still useful with SSH keys only?
Yes, as a second layer: keys stop the guessing from working, fail2ban stops it from filling your logs. With SSH keys only, no password attempt can succeed. Bans still cut the noise and the load from scripts.
Pair it with the UFW limit rule, which blocks fast bursts, while fail2ban handles slow, repeated failures. The offshore VPS security guide puts both in the right order.
fail2ban needs very little memory. According to IronKVM's survey of 16 November 2026, plans comparable to Billet cost a median of $15.00 a month; IronKVM Billet costs $4.46 on 12 months.
fail2ban: questions
What is the best bantime for fail2ban?
The default is 10 minutes. One hour is a common middle ground; longer bans mostly hit addresses that change anyway.
I banned myself. How do I get back in?
Wait for the bantime, or log in from another address and run fail2ban-client set sshd unbanip with your IP.
Can fail2ban protect nginx or WordPress?
Yes. It ships filters for many services; enable the matching jail in jail.local.
Does fail2ban work with UFW?
Yes. Both add rules to the Linux packet filter and can run together.
Does IronKVM install fail2ban for me?
No. Each VPS comes as a clean image of Debian 13, Debian 12, Ubuntu 24.04 LTS, AlmaLinux 10 and Rocky Linux 10.
Verdict
- Two packages and one jail.local file give a VPS automatic bans for repeated SSH failures.
- Set backend = systemd on Debian 13 and check the jail with fail2ban-client status sshd.
Sources (5)
- fail2ban README — fail2ban (read 2026-11-16)
- jail.conf (defaults) — fail2ban (read 2026-11-16)
- jail.conf(5), Debian trixie — Debian (read 2026-11-16)
- fail2ban-client(1), Debian trixie — Debian (read 2026-11-16)
- IronKVM offshore VPS survey (CSV) — IronKVM (read 2026-11-16)
Order a VPS and harden it
Billet, 1 vCPU, 2 GB RAM, 40 GB NVMe, 2 TB traffic, $4.46 a month on 12 months.