{"id":1133,"date":"2026-11-20T18:00:00","date_gmt":"2026-11-20T18:00:00","guid":{"rendered":"https:\/\/vpslake.com\/blog\/?p=1133"},"modified":"2026-11-20T18:00:00","modified_gmt":"2026-11-20T18:00:00","slug":"install-fail2ban-almalinux-10","status":"publish","type":"post","link":"https:\/\/vpslake.com\/blog\/2026\/11\/20\/install-fail2ban-almalinux-10\/","title":{"rendered":"How to Install Fail2Ban on AlmaLinux 10 (Step-by-Step)"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Install Fail2Ban on AlmaLinux 10 to watch failed SSH logins and temporarily block abusive IP addresses through firewalld. This setup takes about ten minutes and leaves you with a persistent SSH jail that reads AlmaLinux\u2019s systemd journal.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Prerequisites<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n\n<li>A fresh AlmaLinux 10 server with at least 1 GB of RAM and 5 GB of free disk space.<\/li>\n\n\n<li>SSH access as <code>root<\/code>, or a normal user with working <code>sudo<\/code> privileges.<\/li>\n\n\n<li>An active <code>sshd<\/code> service and firewalld; this guide does not use Ubuntu\u2019s <code>apt<\/code> or <code>ufw<\/code> commands.<\/li>\n\n\n<li>No domain is required because Fail2Ban protects the server\u2019s SSH service directly.<\/li>\n\n\n<li>A <a href=\"https:\/\/vpslake.com\/buy-vps\">VPSLake Linux VPS<\/a> if you need an AlmaLinux 10 server with administrator access.<\/li>\n\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">The commands use <code>sudo<\/code> for a regular SSH user. If you are logged in as <code>root<\/code>, remove <code>sudo<\/code> from each command.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 1: Confirm AlmaLinux 10 and the SSH firewall state<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Check the release, SSH service, and active firewalld zone first so the jail is attached to the firewall that actually handles incoming traffic.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>grep -E '^(PRETTY_NAME|VERSION_ID|ID_LIKE)=' \/etc\/os-release\nsudo systemctl is-active sshd\nsudo firewall-cmd --state\nsudo firewall-cmd --get-active-zones<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Expected output resembles this; the interface and zone can differ on your VPS:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>PRETTY_NAME=\"AlmaLinux 10.x (Cerulean Lion)\"\nVERSION_ID=\"10.x\"\nID_LIKE=\"rhel centos fedora\"\nactive\nrunning\npublic\n  interfaces: eth0<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If <code>sshd<\/code> is not active, fix SSH access before enabling a protection rule. If firewalld is not running, start it only after confirming your provider\u2019s console access is available in case the existing network policy needs review.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 2: Enable EPEL and install Fail2Ban support packages<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Fail2Ban is distributed for Enterprise Linux through EPEL, while the companion packages connect it to firewalld and the systemd journal. The <a href=\"https:\/\/docs.fedoraproject.org\/en-US\/epel\/getting-started\/\" target=\"_blank\" rel=\"noopener\">EPEL getting-started guide<\/a> documents the EL10 release package used below.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Enable AlmaLinux\u2019s CodeReady Builder-compatible repository and install the official EPEL 10 release package:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo dnf install -y dnf-plugins-core\nsudo dnf config-manager --set-enabled crb\nsudo dnf install -y https:\/\/dl.fedoraproject.org\/pub\/epel\/epel-release-latest-10.noarch.rpm\nsudo dnf makecache<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Install the main daemon together with firewalld actions and systemd-journal integration:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo dnf install -y fail2ban fail2ban-firewalld fail2ban-systemd\nfail2ban-client --version<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The version changes as EPEL publishes updates. A successful check looks similar to this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Fail2Ban v1.1.0<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><code>fail2ban-firewalld<\/code> prevents the common mistake of sending bans to an unrelated iptables action. <code>fail2ban-systemd<\/code> lets the SSH filter read entries from <code>journald<\/code>, which is the normal log source on AlmaLinux 10.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 3: Create a local SSH jail<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Put your changes in a <code>.local<\/code> file under <code>jail.d<\/code> so package upgrades can replace the vendor defaults without erasing your policy. Do not edit <code>\/etc\/fail2ban\/jail.conf<\/code> directly; the <a href=\"https:\/\/github.com\/fail2ban\/fail2ban\/blob\/master\/man\/jail.conf.5\" target=\"_blank\" rel=\"noopener\">Fail2Ban jail configuration reference<\/a> explains the override order.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Create an SSH-only policy with a one-hour ban after five failures in ten minutes:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo install -d -m 0755 \/etc\/fail2ban\/jail.d\nsudo tee \/etc\/fail2ban\/jail.d\/sshd.local &gt;\/dev\/null &lt;&lt;'EOF'\n[DEFAULT]\nignoreip = 127.0.0.1\/8 ::1\nbantime = 1h\nfindtime = 10m\nmaxretry = 5\nbackend = systemd\nbanaction = firewallcmd-rich-rules[actiontype=&lt;multiport&gt;]\n\n[sshd]\nenabled = true\nport = ssh\nfilter = sshd\nEOF<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The loopback addresses are always safe to ignore. If you administer the VPS from a fixed public address, add that address or CIDR to the <code>ignoreip<\/code> line before starting the service so a mistaken password attempt cannot block your workstation. Keep <code>port = ssh<\/code> when SSH uses the standard service definition; for a custom SSH port, replace it with the actual numeric port.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 4: Validate the configuration and start the service<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Test the complete configuration before starting Fail2Ban, then enable it so the SSH jail returns after a reboot.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo fail2ban-client -t\nsudo systemctl enable --now fail2ban\nsudo systemctl status fail2ban --no-pager<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The test and service should report results like these:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>OK: configuration test is successful\n\u25cf fail2ban.service - Fail2Ban Service\n     Active: active (running)<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">A successful configuration test does not mean anyone has been banned yet. It confirms that the jail, filter, backend, and firewalld action can be loaded without a syntax or dependency error.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Verify the SSH jail and firewalld action<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Ask Fail2Ban which jails are loaded, inspect the SSH jail counters, and review its recent service messages:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo fail2ban-client status\nsudo fail2ban-client status sshd\nsudo journalctl -u fail2ban --since \"10 minutes ago\" --no-pager<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">On a newly configured VPS, the counters can be zero. The important values are one loaded jail, <code>sshd<\/code> in the jail list, and a running service:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Status\n|- Number of jail: 1\n`- Jail list: sshd\n\nStatus for the jail: sshd\n|- Filter\n|  |- Currently failed: 0\n|  `- Total failed: 0\n`- Actions\n   |- Currently banned: 0\n   `- Total banned: 0<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Fail2Ban adds a rich rule to the active firewalld zone only when an address reaches <code>maxretry<\/code>. Inspect those rules without generating fake login failures:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo firewall-cmd --list-rich-rules\nsudo systemctl is-enabled fail2ban<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">An empty rich-rule result is normal until a real ban occurs. The final command should print <code>enabled<\/code>, proving the service is configured to start at boot. Do not test by repeatedly guessing passwords from your own workstation; add your trusted address to <code>ignoreip<\/code> and use the status commands instead.<\/p>\n\n\n\n<aside class=\"vl-element vl-cta-banner\" aria-label=\"Get a secure Linux VPS\">\n\t<div class=\"vl-cta-banner__content\">\n\t\t<p class=\"vl-cta-banner__eyebrow\">Protect your server<\/p>\n\t\t<h3 class=\"vl-cta-banner__title\">Get a secure Linux VPS<\/h3>\n\t\t<p class=\"vl-cta-banner__text\">Deploy AlmaLinux 10 with root access and harden SSH with Fail2Ban from the beginning.<\/p>\n\t<\/div>\n\t<a class=\"vl-cta-banner__button\" href=\"\/buy-vps\" aria-label=\"Get a Linux VPS\">Get a Linux VPS<\/a>\n<\/aside>\n\n\n\n<h2 class=\"wp-block-heading\">Troubleshooting<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><code>FirewallD is not running<\/code><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The firewalld action cannot add or remove bans when its daemon is stopped. Confirm that the server is reachable through your provider console, then run <code>sudo systemctl enable --now firewalld<\/code> and <code>sudo firewall-cmd --state<\/code> before restarting Fail2Ban.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><code>Unable to read the systemd journal<\/code> or a missing systemd backend<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The journal integration package may not be installed, or the jail may be using a file backend. Install the matching package and keep <code>backend = systemd<\/code> in <code>sshd.local<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo dnf install -y fail2ban-systemd\nsudo fail2ban-client -t\nsudo systemctl restart fail2ban<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><code>Jail 'sshd' does not exist<\/code><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Fail2Ban did not load the section, usually because the file was saved under the wrong path or the section name is misspelled. Check the file and rerun the configuration test:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo sed -n '1,120p' \/etc\/fail2ban\/jail.d\/sshd.local\nsudo fail2ban-client -t<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The file must contain the exact <code>[sshd]<\/code> header and <code>enabled = true<\/code>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">The service reports an iptables action error<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">An old configuration may force <code>banaction = iptables-multiport<\/code>, which conflicts with AlmaLinux\u2019s firewalld workflow. Remove that override and use <code>banaction = firewallcmd-rich-rules[actiontype=&lt;multiport&gt;]<\/code>, install <code>fail2ban-firewalld<\/code>, then restart Fail2Ban.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Hardening<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n\n<li>Use SSH keys and disable password authentication only after opening a second verified session; Fail2Ban reduces repeated guesses but cannot repair weak credentials.<\/li>\n\n\n<li>Restrict SSH in firewalld to your office or VPN source when your administration network has a stable address.<\/li>\n\n\n<li>Add a fixed administrator address to <code>ignoreip<\/code>, but do not whitelist broad public ranges.<\/li>\n\n\n<li>For a guided SSH policy, the <a href=\"https:\/\/vpslake.com\/sshd-hardening-generator\">VPSLake SSH hardening generator<\/a> can produce a starting configuration to review before applying.<\/li>\n\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">FAQ<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Does Fail2Ban replace firewalld on AlmaLinux 10?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">No. Fail2Ban reads authentication events and asks firewalld to add temporary source-address blocks. Keep the firewall configured with only the services and ports your VPS needs.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Why does the installation need EPEL?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Fail2Ban is not part of the standard AlmaLinux BaseOS package set. EPEL supplies the AlmaLinux-compatible daemon plus optional packages for firewalld actions and systemd journal input.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">How long does a banned IP stay blocked?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The example uses <code>bantime = 1h<\/code>, so a ban expires after one hour unless the address is banned again. Change the value to formats such as <code>30m<\/code>, <code>12h<\/code>, or <code>1d<\/code> when your traffic pattern justifies it.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">How do I remove a legitimate address from the ban list?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">First add the address to <code>ignoreip<\/code> and restart the service so it will not be banned again. Then remove the current ban with <code>sudo fail2ban-client set sshd unbanip ADMIN_IP<\/code>, replacing <code>ADMIN_IP<\/code> with the affected address.<\/p>\n\n\n\n<script type=\"application\/ld+json\">{\"@context\": \"https:\/\/schema.org\", \"@type\": \"FAQPage\", \"mainEntity\": [{\"@type\": \"Question\", \"name\": \"Does Fail2Ban replace firewalld on AlmaLinux 10?\", \"acceptedAnswer\": {\"@type\": \"Answer\", \"text\": \"No. Fail2Ban reads authentication events and asks firewalld to add temporary source-address blocks. Keep the firewall configured with only the services and ports your VPS needs.\"}}, {\"@type\": \"Question\", \"name\": \"Why does the installation need EPEL?\", \"acceptedAnswer\": {\"@type\": \"Answer\", \"text\": \"Fail2Ban is not part of the standard AlmaLinux BaseOS package set. EPEL supplies the AlmaLinux-compatible daemon plus optional packages for firewalld actions and systemd journal input.\"}}, {\"@type\": \"Question\", \"name\": \"How long does a banned IP stay blocked?\", \"acceptedAnswer\": {\"@type\": \"Answer\", \"text\": \"The example uses `bantime = 1h`, so a ban expires after one hour unless the address is banned again. Change the value to formats such as `30m`, `12h`, or `1d` when your traffic pattern justifies it.\"}}, {\"@type\": \"Question\", \"name\": \"How do I remove a legitimate address from the ban list?\", \"acceptedAnswer\": {\"@type\": \"Answer\", \"text\": \"First add the address to `ignoreip` and restart the service so it will not be banned again. Then remove the current ban with `sudo fail2ban-client set sshd unbanip ADMIN_IP`, replacing `ADMIN_IP` with the affected address.\"}}]}<\/script>\n\n","protected":false},"excerpt":{"rendered":"Install Fail2Ban on AlmaLinux 10 with EPEL, firewalld, and the systemd journal, then protect SSH with a tested jail and useful fixes on your VPS.","protected":false},"author":1,"featured_media":1134,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"csco_singular_sidebar":"","csco_page_header_type":"","csco_page_load_nextpost":"","footnotes":""},"categories":[5,13],"tags":[91,141,143,142],"class_list":["post-1133","post","type-post","status-publish","format-standard","has-post-thumbnail","category-guides","category-server-security","tag-almalinux-10","tag-fail2ban","tag-firewalld","tag-ssh-security","cs-entry"],"_links":{"self":[{"href":"https:\/\/vpslake.com\/blog\/wp-json\/wp\/v2\/posts\/1133","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/vpslake.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vpslake.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vpslake.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/vpslake.com\/blog\/wp-json\/wp\/v2\/comments?post=1133"}],"version-history":[{"count":1,"href":"https:\/\/vpslake.com\/blog\/wp-json\/wp\/v2\/posts\/1133\/revisions"}],"predecessor-version":[{"id":4132,"href":"https:\/\/vpslake.com\/blog\/wp-json\/wp\/v2\/posts\/1133\/revisions\/4132"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/vpslake.com\/blog\/wp-json\/wp\/v2\/media\/1134"}],"wp:attachment":[{"href":"https:\/\/vpslake.com\/blog\/wp-json\/wp\/v2\/media?parent=1133"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vpslake.com\/blog\/wp-json\/wp\/v2\/categories?post=1133"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vpslake.com\/blog\/wp-json\/wp\/v2\/tags?post=1133"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}