← 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
  1. rn
  2. Update your system and install Fail2Banrn
    • rn
    • sudo apt updaternsudo apt install fail2banrn
    rnrn
  3. Copy the default configuration filern
    • rn
    • sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.localrn
    rnrn
  4. Edit the configuration to protect SSHrn
    • rn
    • sudo nano /etc/fail2ban/jail.localrn
    • Look for the [sshd] section and make sure it looks like this:rn
    • [sshd]rnenabled = truernport = sshrnfilter = sshdrnlogpath = /var/log/auth.logrnmaxretry = 5rnbantime = 3600rn
    rnrn
  5. Restart and enable Fail2Banrn
  6.  Check Fail2Ban statusrn
    • rn
    • sudo fail2ban-client statusrnsudo fail2ban-client status sshdrn
    rnrn
  7. 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.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