heyer.systems

fail2ban

Blocks IP addresses after repeated failed SSH logins (nftables); own jails for app logins possible

fail2ban LXCVM

Add to a guest

In the guest as root – container and VM alike:

update --add-modules fail2ban

Runs a normal update and installs the module on the way.

From the Proxmox node, without logging in:

pct exec <ID> -- update --add-modules fail2ban   # container
ssh root@<IP> update --add-modules fail2ban

Choose when creating a guest

Without a dialog, on the Proxmox node:

IAC_NONINTERACTIVE=1 var_modules=auto-update,fail2ban \
  bash -c "$(curl -fsSL https://iac.heyer.systems/<app>/ct.sh)"

var_modules replaces the app's preselection – keep auto-update in the list if you want it. Interactive: choose “advanced” in the dialog, or tick the module in the generator on the app page.

Remove

update --remove-modules fail2ban

Removes the module's packages, services, firewall rules and configuration again. Data stays.

Details

Blocks IP addresses after 5 failed SSH logins within 10 minutes – for one hour first, longer on repeat (up to one week). It blocks with nftables in a table of its own, the iac firewall stays untouched.

fail2ban-client status sshd                    # blocked addresses
fail2ban-client set sshd unbanip 192.0.2.10    # lift a ban

Own jails (e.g. for the login of a web app) and other limits go into /etc/fail2ban/jail.d/*.local.