Skip to content
BENIBIX Learn

Fail2ban

Infrastructure🔑 SSH & Remote AccessSSH Login Security

Also known as fail2ban, fail2ban-client, SSH Ban Tool

A tool that blocks an address when it fails to log in too often.

Think of it like

Think of it like a guard at a door. Get the word wrong too many times, and he sends you away.

Example

A bot tries hundreds of passwords on Jack's server. Fail2ban spots it in the log and blocks its address at the firewall.

Why it matters

It cuts the noise of attacks and blocks slow password guessing on any service with a log.

Definition

Fail2ban is a tool that bans addresses that fail to log in too often. It reads the server's logs and counts failed logins. When one address fails too many times, it adds a firewall rule to block it for a while. It is most often used to guard SSH. It slows guessing down, but it does not replace keys.

Example code

bash
sudo apt install fail2ban
sudo fail2ban-client status sshd
Install it, then ask which addresses the SSH guard has banned.
Fail2ban reads the log and sees one address fail again and again. It bans it at the firewall.

Common mistake

Thinking fail2ban makes password login safe. A patient bot from many addresses still gets through, so use keys.

Key takeaways

  1. 1
    Reads logs. Counts failed logins.
  2. 2
    Bans at the firewall. Blocks the address for a while.
  3. 3
    Not a lock. Keys still matter most.

Learn it properly