Guides · Linux servers · 3 min read

fail2ban will not start on Debian 12

Debian 12 and later log SSH logins to the systemd journal only, so the default sshd jail has no file to read and fail2ban exits. Tell it to read the journal.

Tested on Debian 12 and 13, Ubuntu 24.04

What you see

You installed fail2ban and enabled the sshd jail. systemctl status fail2ban shows it failed, and the journal says the log file it needs is missing:

$ journalctl -u fail2ban -n 20 ... ERROR Failed during configuration: Have not found any log file for sshd jail ... fail2ban.service: Main process exited, code=exited, status=255/EXCEPTION

Why it happens

fail2ban's sshd jail reads /var/log/auth.log by default. Debian 12 no longer installs rsyslog, so nothing writes that file: SSH logins go to the systemd journal only. Ubuntu still writes /var/log/auth.log, which is why the same setup works there.

The fix: read the journal

  1. Install the Python bindings fail2ban uses to read the journal: python3-systemd.
  2. Put your jail settings in a file of their own under /etc/fail2ban/jail.d/ (never edit jail.conf: updates replace it) with backend = systemd.
  3. Restart fail2ban and check that the jail is running.
apt-get install -y fail2ban python3-systemd cat > /etc/fail2ban/jail.d/sshd.local <<'EOF' [sshd] enabled = true backend = systemd maxretry = 5 bantime = 1h EOF systemctl restart fail2ban fail2ban-client status sshd

Check it works

fail2ban-client status sshd lists the jail with its counters. Failed logins from the internet arrive within minutes on any public server, so Currently failed should start counting soon. Before you test a ban from your own address, make sure you can still reach the server another way (your provider's console), or add your address to ignoreip in the same file.

Or hand it to your AI

With AskYourStack connected, Claude, ChatGPT or Cursor can do this on your server, following our tested playbook, and nothing changes until you open changes on that server. Paste this:

Set up fail2ban for SSH on my server and show me it is working.

More: Server hardening with your AI, VPS setup.

More guides