Security13 min read•Updated November 2026

VPS Hosting for Fail2ban

Quick answer

Fail2ban watches log files for repeated failures, such as wrong SSH passwords or failed web logins, and temporarily bans the offending IPs through the firewall (iptables, nftables or UFW). Configure it in jail.local: enable the sshd jail, add jails for Nginx, mail or application logins with suitable filters, set maxretry, findtime and bantime, enable the recidive jail for repeat offenders, and whitelist your own IPs with ignoreip. Test filters with fail2ban-regex, check bans with fail2ban-client, and remember it complements, not replaces, SSH keys and a firewall.

Within minutes of a VPS getting a public IP, automated bots start guessing SSH passwords. Fail2ban has been the standard answer for years: simple, light and effective against brute-force attempts that leave traces in logs. It is not a complete security solution, but it reduces noise, slows attackers and protects services that must accept password logins. This guide covers a practical configuration.

Jails, Filters and Actions

  • Filter: regular expressions that recognise failure lines in a log.
  • Jail: combines a log path, a filter and settings such as how many failures within what time trigger a ban.
  • Action: what happens on a ban, usually a firewall rule, optionally an email or webhook.

Fail2ban ships filters for many services (sshd, nginx-http-auth, postfix, dovecot and more). You configure jails in /etc/fail2ban/jail.local rather than editing the defaults.

Protecting SSH

Enable the sshd jail with sensible values, for example a ban after five failures within ten minutes, lasting one hour or more. Better still, disable SSH password authentication entirely and use keys (see our SSH keys guide); Fail2ban then mainly reduces log noise and blocks scanners. On systems using the systemd journal, configure the jail's backend to read the journal.

Key Settings

SettingMeaningTypical value
maxretryFailures allowed before a ban3–5
findtimeWindow for counting failures10m
bantimeBan duration1h or longer
ignoreipIPs never bannedYour office, VPN, monitoring
banactionFirewall integrationnftables, iptables or ufw

Repeat Offenders

The recidive jail watches Fail2ban's own log and bans IPs that keep getting banned, for much longer (for example a week). It is an easy way to deal with persistent bots without making the first ban excessively long. Incremental ban times, where each repeat ban grows, achieve something similar.

Web Applications

  • Use bundled filters for HTTP authentication failures and common bad bots.
  • For application logins (WordPress, custom apps), log failed logins with the client IP in a consistent format and write a filter for it.
  • If your site is behind a CDN or reverse proxy, log the real client IP; otherwise Fail2ban will ban the proxy.
  • Consider rate limiting in Nginx for login endpoints as well.

Firewall Integration

Choose a ban action matching your firewall. With UFW, use the UFW action so bans appear alongside your rules (see our UFW guide). With nftables or iptables, use the corresponding actions. Bans should drop traffic from the IP to the relevant port, or to all ports for aggressive offenders.

Testing Filters

Use fail2ban-regex with a log file and filter to see how many lines match before enabling a jail. After enabling, use fail2ban-client status and fail2ban-client status sshd to see active bans, and unban test IPs with fail2ban-client set sshd unbanip.

Limitations

  • Fail2ban reacts after failures appear in logs; it does not prevent the first attempts.
  • Distributed attacks from many IPs with few attempts each may stay under thresholds.
  • It does not stop DDoS floods, which need provider mitigation (see our firewall vs DDoS guide).
  • For shared threat intelligence and multi-server bans, consider CrowdSec.

Monitoring

Review Fail2ban's log and ban counts periodically, send notable events to your log system or SIEM (see our Wazuh guide), and alert if the Fail2ban service stops.

Example: A Small Business Server

A VPS hosting a company website and mail server runs Fail2ban with jails for sshd (keys only, so mostly scanners), Postfix and Dovecot authentication, Nginx HTTP auth on the admin area and recidive with a one-week ban. The office IP and uptime monitor are in ignoreip. Authentication failures in the logs dropped by more than 90% within days.

Common Mistakes

  • Editing jail.conf instead of jail.local, losing changes on upgrade.
  • Forgetting ignoreip and locking yourself out.
  • Banning the CDN or proxy IP instead of the client.
  • Relying on Fail2ban while allowing SSH passwords.
  • Filters that do not match the actual log format, so nothing is banned.

In Short

Enable the sshd jail, add jails for your other login points, tune retries and ban times, use recidive, whitelist yourself, test filters and pair Fail2ban with SSH keys, a firewall and provider DDoS protection.

Writing a Custom Filter

For an application login, first make the application log failures in a predictable line, for example a timestamp, the words "login failed" and the client IP. Create a filter file in filter.d with a failregex that matches that line and captures the host with Fail2ban's <HOST> placeholder. Run fail2ban-regex against a real log to confirm it matches failures but not successful logins, then add a jail pointing at the log with conservative retry and ban settings. Reload Fail2ban and trigger a few failures from a test IP to confirm the ban works before relying on it.

Next Steps

Disable SSH passwords, enable the sshd and recidive jails, whitelist your IPs, add jails for each login point, and test everything with fail2ban-regex and a test IP. Security tools are only as good as the people and routines around them, so assign an owner, schedule regular reviews and record what you change and why. Start small on one server, measure the results for a couple of weeks, and only then roll the same configuration out to the rest of your infrastructure, adjusting it for each server's role. When something unexpected appears, investigate calmly, preserve logs before changing anything, and write a short note afterwards about what happened, what you learned and what you changed to prevent it next time. If you are unsure where to begin, protect the services that face the internet first, such as SSH, administrative panels and login pages, because they receive the most automated attacks and give the quickest visible improvement.

SkyRainCloud Plans for This Workload

Fail2ban needs negligible resources and runs on any SkyRainCloud VPS alongside your applications.

AMD EPYC 7C13 VPS

Dedicated KVM vCores on AMD EPYC 7C13 (up to 3.70 GHz) with DDR4 ECC memory, NVMe SSD and an unmetered 1 Gbps port.

PlanvCoresRAMStorageNetworkPriceGood forBuy
VPS 1 — AMD28 GB DDR4 ECC40 GB NVMe SSD1 Gbps, unmetered₹649/monthWebsites, small APIs, bots, staging and VPN serversOrder
VPS 2 — AMD416 GB DDR4 ECC80 GB NVMe SSD1 Gbps, unmetered₹1,299/monthWooCommerce, Node.js/Python backends, Docker Compose stacks, CI runnersOrder
VPS 3 — AMD832 GB DDR4 ECC150 GB NVMe SSD1 Gbps, unmetered₹2,499/monthProduction databases, high-traffic sites, multi-container appsOrder
VPS 4 — AMD1664 GB DDR4 ECC250 GB NVMe SSD1 Gbps, unmetered₹4,899/monthLarge production workloads, SaaS platforms, analytics, in-memory cachesOrder

Intel Xeon Platinum 8269CY VPS

KVM VPS on Intel Xeon Platinum 8269CY (up to 3.80 GHz Turbo) with DDR4 ECC memory, NVMe SSD, full root access and an unmetered 1 Gbps port.

PlanvCoresRAMStorageNetworkPriceGood forBuy
VPS 1 — Intel28 GB DDR4 ECC40 GB NVMe SSD1 Gbps, unmetered₹649/monthBusiness websites, small apps, scheduled jobs and botsOrder
VPS 2 — Intel416 GB DDR4 ECC80 GB NVMe SSD1 Gbps, unmetered₹1,169/monthBusiness software, mid-size databases, several sites on one serverCheck stock
VPS 3 — Intel832 GB DDR4 ECC150 GB NVMe SSD1 Gbps, unmetered₹2,249/monthERP/CRM stacks, heavier databases, multiple production appsCheck stock
VPS 4 — Intel1664 GB DDR4 ECC250 GB NVMe SSD1 Gbps, unmetered₹4,299/monthHigh-memory workloads and consolidated production serversCheck stock

Prices are monthly in INR as listed on the SkyRainCloud store (verified 2026-11-14). Stock and final pricing are shown on the product page at checkout.

Frequently Asked Questions

What does Fail2ban do?
It watches logs for repeated failures and temporarily bans offending IPs through the firewall.
Where should I configure Fail2ban?
In jail.local, not the default jail.conf.
What is a jail?
A configuration combining a log, a filter and ban settings for one service.
What are good Fail2ban settings for SSH?
Ban after about five failures in ten minutes for an hour or more, and use SSH keys.
What is the recidive jail?
A jail that bans repeat offenders for much longer based on Fail2ban's own log.
Does Fail2ban work with UFW?
Yes, use the UFW ban action.
How do I test a filter?
Run fail2ban-regex against a log file and the filter.
Can Fail2ban stop DDoS attacks?
No, it handles brute-force patterns; floods need provider mitigation.
How do I unban an IP?
Use fail2ban-client set with the jail name and unbanip.
Which plan suits Fail2ban?
Any VPS; Fail2ban uses negligible resources.
Instant UPI • ₹649/mo
Fast KVM Cloud Provisioning