No KYC · KVM in Hong Kong, Tokyo and Singapore at one price · Pay in BTC, USDT, USDC, ETH, SOL, LTC, XMR
Language: English
Build a server

Guide · Debian 13 and Ubuntu 24.04 · checked 16 November 2026

How do you install fail2ban on a VPS?

This is how to install fail2ban on a VPS running Debian 13 or Ubuntu 24.04, where SSH failures are read from the systemd journal.

Last updated: · 4 min read

Quick answer

How do you install fail2ban on a VPS?

To install fail2ban on a VPS, run apt install fail2ban python3-systemd, write a jail.local that turns on the sshd jail with the systemd backend, then restart the service. A ban of 1 hour after 5 failures is a sane start. JadeKVM servers run Debian or Ubuntu images where this works as shown.

In brief
  • jail.local, never jail.conf: package updates overwrite jail.conf.
  • systemd backend: Debian 13 has no /var/log/auth.log by default, so fail2ban reads the journal.
  • Whitelist yourself: put your fixed home or office IP in ignoreip.
  • Check with fail2ban-client status sshd to see failures and bans.

How to install fail2ban on a VPS in 5 steps?

Run the commands as a sudo user. Keep a second SSH window open while you test.

  1. Install the packages

    Run sudo apt install fail2ban python3-systemd. The second package lets fail2ban read the journal.

  2. Create jail.local

    Write the sshd jail with backend = systemd, maxretry, findtime and bantime.

  3. Add your own address

    Put your fixed IP in ignoreip, so a typo never bans you.

  4. Restart and enable

    Run sudo systemctl enable --now fail2ban, then sudo systemctl restart fail2ban after each change.

  5. Check the jail

    Run sudo fail2ban-client status sshd and read the failed and banned counters.

Which fail2ban settings matter most?

Key fail2ban settings for the sshd jail, a starting value and what each one does
SettingStarting valueWhat it doesTune it when
backendsystemdReads SSH failures from the journalNever on Debian 13 or Ubuntu 24.04
maxretry5Failures before a banLower to 3 with keys-only login
findtime10mWindow in which failures countRaise for slow, patient bots
bantime1hLength of a banRaise to 1d for repeat offenders
ignoreip127.0.0.1/8 ::1 plus your IPAddresses never bannedYou have a fixed address

Why does fail2ban need the systemd backend on Debian 13?

Debian 13 logs SSH to the systemd journal and ships no rsyslog, so the classic auth.log file is missing. A jail that watches a missing file fails to start. With backend = systemd, fail2ban queries the journal directly. Ubuntu 24.04 still writes auth.log, but the journal works there too, so one config fits both.

The file below is complete for a server that only exposes SSH. Change 198.51.100.7 to your own fixed address, or remove it if your address changes.

/etc/fail2ban/jail.local
[DEFAULT]
ignoreip = 127.0.0.1/8 ::1 198.51.100.7
bantime  = 1h
findtime = 10m
maxretry = 5

[sshd]
enabled = true
backend = systemd

How do you check bans and unban an address?

Use fail2ban-client: status shows the counters, and unban removes one address. Bans become firewall rules, so they hold even if UFW allows SSH. A ban ends by itself after bantime.

On a new public server, the banned list often fills within a day. That is normal background noise. It also shows why keys-only login matters more than any ban.

Status and unban
sudo fail2ban-client status
sudo fail2ban-client status sshd
sudo fail2ban-client set sshd unbanip 203.0.113.55
sudo journalctl -u fail2ban --since today

Which is better on a VPS: fail2ban or UFW limit?

Use both: they act at different layers. ufw limit slows any address that opens six connections in 30 seconds. Fail2ban reads real login failures and bans for longer. The guide on how to set up a UFW firewall on a VPS shows the limit rule.

JadeKVM read WonderNetwork's public pings on 16 November 2026: Tokyo sits 35 ms from Seoul and 31 ms from Taipei. Latency figures on JadeKVM pages are public averages measured by WonderNetwork between its own servers on 16 November 2026; they show how far apart the cities sit on the network, not a promise about any one JadeKVM server. Neither tool changes those round trips.

Can fail2ban protect nginx or WordPress too?

Yes, with extra jails such as nginx-http-auth or a filter for wp-login.php. Each jail needs the log file of that service and a matching filter in /etc/fail2ban/filter.d/. Start with sshd only; add web jails once the site runs, as in how to install WordPress on a VPS.

Questions about fail2ban on a VPS

Do I still need fail2ban with SSH keys only?

It is less critical, since passwords cannot be guessed. It still trims log noise and slows scans. On a JadeKVM server with a key pasted at checkout, it is a second layer.

Why does fail2ban fail to start on Debian 13?

Usually because the sshd jail looks for /var/log/auth.log. Add backend = systemd and install python3-systemd.

What is the best bantime for a VPS in 2026?

One hour is a good start. Enable the recidive jail to ban repeat offenders for a week.

Does fail2ban work with IPv6?

Yes, recent versions ban IPv6 addresses too. Debian 13 and Ubuntu 24.04 ship versions with IPv6 support.

Can I ban myself?

Yes, by typing wrong too often. Add your fixed IP to ignoreip, or unban yourself from another address.

Verdict
  • Install fail2ban with python3-systemd and backend = systemd: that is what works on Debian 13 and Ubuntu 24.04.
  • Pair it with UFW and keys-only login; fail2ban is a filter, not a lock.
Sources (4)
  1. Fail2ban project and documentation — Fail2ban (read 2026-11-16)
  2. fail2ban package, Debian 13 (trixie) — Debian (read 2026-11-16)
  3. Security, Ubuntu Server documentation — Canonical (read 2026-11-16)
  4. WonderNetwork: pings from Tokyo wondernetwork.com/pings/Tokyo — WonderNetwork (read 2026-11-16)

Run fail2ban on a Tokyo server

Pendant in Tokyo costs $4.50 a month on 12 months, with your SSH key in place.

From $3.75/mo on 12 months · HK · TYO · SIN

Build