DMCA notices: no action · Netherlands · Romania · Moldova · Pay in BTC, USDT, USDC, ETH, SOL, LTC, XMR
Language: English
Configure a VPS

Guide · ban repeated SSH failures

How to install fail2ban?

fail2ban reads login failures and bans the addresses behind them for a while. One short jail.local file is all a VPS needs.

Last updated: · 4 min read

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?

Main fail2ban settings, their defaults in jail.conf and the values used in this guide, from the fail2ban project and its Debian manual
SettingDefaultThis guideMeaning
bantime10m1hHow long an address stays banned
findtime10m10mWindow in which failures are counted
maxretry55Failures that trigger a ban
backendautosystemdWhere log lines are read
enabledfalsetrue for sshdWhether the jail runs
ignoreipnot setyour fixed IPAddresses never banned

What are the steps to install fail2ban?

  1. Install the packages

    Install fail2ban and python3-systemd so the systemd backend can read the journal.

  2. Create jail.local

    Write your settings in /etc/fail2ban/jail.local. jail.conf may be replaced by package updates.

  3. Enable the sshd jail

    Set enabled = true and backend = systemd under [sshd].

  4. Whitelist your own address

    Add your fixed IP to ignoreip if you have one, so a typo never bans you.

  5. Start the service

    Enable fail2ban at boot and restart it to load the file.

  6. Check the jail

    Run fail2ban-client status sshd to see failures and banned addresses.

Install and configure
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 fail2ban
Check and unban
sudo fail2ban-client ping
sudo fail2ban-client status
sudo fail2ban-client status sshd
sudo fail2ban-client set sshd unbanip 203.0.113.5

Why 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)
  1. fail2ban README — fail2ban (read 2026-11-16)
  2. jail.conf (defaults) — fail2ban (read 2026-11-16)
  3. jail.conf(5), Debian trixie — Debian (read 2026-11-16)
  4. fail2ban-client(1), Debian trixie — Debian (read 2026-11-16)
  5. 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.

From $4.46/month · no KYC

Configure a VPS