← Volver al blog

How to Secure Your VPS with Fail2Ban

  • Xernode
  • 1 min de lectura
  • 1 de abril de 2026
Security fail2ban security linux vps brute force

Introduction

rnFail2Ban is a powerful tool that protects your VPS from brute-force attacks by monitoring log files and banning suspicious IPs automatically. This guide shows you how to install and configure Fail2Ban for better server security.rn

Step-by-step Guide

rn
    rn
  1. Update your system and install Fail2Banrn
      rn
    • sudo apt updaternsudo apt install fail2ban
    • rn
    rn
  2. rn
  3. Copy the default configuration filern
      rn
    • sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
    • rn
    rn
  4. rn
  5. Edit the configuration to protect SSHrn
      rn
    • sudo nano /etc/fail2ban/jail.local
    • rn
    • Look for the [sshd] section and make sure it looks like this:
    • rn
    • [sshd]rnenabled = truernport = sshrnfilter = sshdrnlogpath = /var/log/auth.logrnmaxretry = 5rnbantime = 3600
    • rn
    rn
  6. rn
  7. Restart and enable Fail2Ban
  8. rn
  9.  Check Fail2Ban statusrn
      rn
    • sudo fail2ban-client statusrnsudo fail2ban-client status sshd
    • rn
    rn
  10. rn
  11. RecommendationsrnAdjust maxretry and bantime to fit your security needs.rnRegularly check the Fail2Ban logs for blocked IPs.rnYou can protect other services (like Apache, Nginx, etc.) by enabling their respective jails in the config.
  12. rn
rnCall To ActionrnWant a secure VPS with full root access? Check out our hosting plans! https://xernode.com/#pricingrnrnRelated GuidesrnHow to Enable Firewall (UFW) in UbunturnHow to Set Up Automatic Backups in Linux