Quick Overview - Install and Configure Fail2Ban on Ubuntu Linux 26.04
Fail2Ban is an open-source intrusion prevention tool that watches your server logs and bans IPs that fail authentication too many times. Here's the full process on Ubuntu Linux 26.04:- Install the
fail2banpackage from the default Ubuntu repositories. - Manage the service through
systemctl(start, stop, enable on boot). - Create a
/etc/fail2ban/jail.localfile to override the default settings. - Enable the SSH jail with custom
maxretry,findtime, andbantimevalues. - Validate the configuration and restart the service.
- Integrate Fail2Ban with
ufwto manage firewall rules. - Test by simulating failed SSH logins from a second machine to confirm bans are applied automatically.
Prerequisites
Before you start:- Deploy an Ubuntu server.
- Running Fail2Ban on a VPS gives you a 24/7 hardened, internet-facing host that can actually be attacked, monitored, and recovered remotely. If you don't have a server yet, SSD Nodes offers the most affordable Linux VPS hosting in the market with lifetime price locks, 24/7 support, and a 14-day money-back guarantee. You can get an 8GB VPS for just $5.50/month on the 3-year plan, with 1-Click Apps for instant Ubuntu deployment. Spin one up, try it, and get a full refund if it's not the right fit.
- SSH to your server using PuTTY for Windows or OpenSSH for Linux and Mac OS.
- Create a non-root user with
sudoprivileges. You will use this user account to run all commands in this guide.
Install Fail2Ban
The Fail2Ban package is available in the default Ubuntu 26.04 repositories. Installing the software adds the core functionality, including the main daemon, default jails, and action scripts that block malicious IP addresses. Follow the steps below to install Fail2Ban.- Update your system's package information index.
$ sudo apt update - Install Fail2Ban using
apt, a command-line utility that manages packages on Ubuntu.$ sudo apt install -y fail2ban - Check the version to verify you've installed Fail2Ban.
Output:$ fail2ban-client --versionFail2Ban v1.1.0
Manage Fail2Ban Service
On Ubuntu 26.04, Fail2Ban runs as a system service under the namefail2ban. Understanding how to manage this service allows you to control Fail2Ban, apply configuration changes, and troubleshoot issues when they arise.
Check Fail2Ban Service Status
- Verify that the Fail2Ban service is active and running.
Output:$ sudo systemctl status fail2ban
Press ctrl + c to exit the status view.● fail2ban.service - Fail2Ban Intrusion Prevention System Loaded: loaded (/usr/lib/systemd/system/fail2ban.service; enabled; preset: enabled) Active: active (running) since Tue 2026-04-29 10:15:22 UTC; 2min ago Docs: man:fail2ban(1) Main PID: 1245 (fail2ban-server) Tasks: 5 (limit: 2275) Memory: 13.2M CPU: 234ms
Start, Stop, and Restart Fail2Ban
- Stop the Fail2Ban service if you need to disable the service
Continue reading this article
by subscribing to our newsletter.
Subscribe nowby subscribing to our newsletter.