Special Offers: Up to 75% OFF on Hostinger & High-RAM Contabo Cloud VPS available this month.Compare Plans

How to Secure Linux VPS with Fail2ban & SSH Key Authentication: Stop Brute-Force Attacks

Viktor Chen
Viktor ChenSystems Performance Engineer
November 21, 2026
•
14 min read
•
4.9 / 5.0
Transparency Notice: This article contains affiliate links to hosting providers like Hostinger and Contabo. If you purchase through our links, we may earn a commission at zero extra cost to you. We only recommend products we personally benchmark and test. Read full disclosure.
How to Secure Linux VPS with Fail2ban & SSH Key Authentication: Stop Brute-Force Attacks

Hostinger vs. Contabo: Full Specifications Breakdown

Data verified from our lab benchmarks • Updated for 2026

Feature / Metric
HostingerEditor's Choice UI
ContaboMax RAM Value
Starting Price$2.99 / month (Web) | $4.99 / mo (VPS)$5.50 / month (Cloud VPS S)
vCPU Cores1 to 8 vCPU (Dedicated resources)4 to 12 vCPU (High Core Count)
RAM Memory4 GB to 32 GB6 GB to 64 GB (Gigantic RAM)
Storage Technology50 GB – 400 GB NVMe SSD50 GB NVMe or 300 GB SSD
Traffic / Bandwidth4 TB to 32 TB32 TB Outgoing + Unlimited In
Control Panel & UIhPanel (Ultra Modern & Easy)cPanel, Plesk, Webmin, or CLI
Customer Support24/7 Live Chat & AI Support (Multi-lingual)Email Ticket Support (German Business Hours)
Best ForBloggers, WordPress Sites & Devs wanting easy UIHeavy Database, Docker, Game Servers & SysAdmins
Money-Back Guarantee30-Day Money-Back Guarantee14-Day EU Statutory Cancellation
Official LinksVisit HostingerVisit Contabo
Quick Answer & Key Takeaways
Updated November 21, 2026 • Lab Score 4.9/5.0

Within 10 minutes of launching a public VPS, automated bots begin brute-forcing port 22. Learn how to secure your server with SSH keys, non-standard ports, and Fail2ban.

  • Permanently halts automated dictionary attacks and password-guessing botnets
  • Ed25519 cryptographic SSH keys provide mathematical immunity against brute-force penetration
  • Fail2ban automatically writes dynamic firewall drop rules against repeat offenders

The Threat Landscape for New VPS Deployments

Every public IPv4 address on the internet is continuously scanned by automated botnets within minutes of being provisioned on Contabo or Hostinger. If you check your auth log with grep 'Failed password' /var/log/auth.log, you will likely see thousands of failed SSH login attempts from IP addresses worldwide trying generic usernames like root, admin, test, and ubuntu.

Leaving root password authentication enabled on default port 22 is an unacceptable security vulnerability. In this guide, we implement a three-tiered security shield: Ed25519 SSH Key Authentication, custom port assignment, and Fail2ban automated intrusion prevention.

Step 1: Generate an Ed25519 SSH Key Pair

On your local computer (Mac, Linux, or Windows PowerShell), generate an ultra-secure Ed25519 SSH key:

ssh-keygen -t ed25519 -C "admin@yourdomain.com"

Copy your public key to your VPS server:

ssh-copy-id -i ~/.ssh/id_ed25519.pub root@YOUR_SERVER_IP

Step 2: Hardening the SSH Daemon Configuration

SSH into your VPS and edit the main OpenSSH daemon configuration file:

sudo nano /etc/ssh/sshd_config.d/99-hardened.conf

Paste the following security directives (choosing a custom high port such as 2244):

# Change default port to evade automated port scanners
Port 2244

# Disable root login and enforce cryptographic keys only
PermitRootLogin prohibit-password
PasswordAuthentication no
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys

# Restrict authentication attempts
MaxAuthTries 3
ClientAliveInterval 300
ClientAliveCountMax 2
X11Forwarding no

Critical Rule: Update Firewall Before Restarting SSH!

If you change your SSH port to 2244 without updating UFW firewall rules, you will lock yourself out of your server! Run the following commands before restarting SSH:

sudo ufw allow 2244/tcp
sudo ufw enable
sudo sshd -t
sudo systemctl restart ssh

Do not close your current terminal window! Open a new local terminal and test connecting with your key over the new port:

ssh -p 2244 -i ~/.ssh/id_ed25519 root@YOUR_SERVER_IP

Step 3: Installing & Configuring Fail2ban

Fail2ban monitors system log files and dynamically modifies your netfilter/iptables firewall to drop IP addresses that display malicious login behavior. Install Fail2ban:

sudo apt update && sudo apt install -y fail2ban

Create a local jail override file:

sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
sudo nano /etc/fail2ban/jail.local

Configure the [sshd] section with your custom port and aggressive ban rules:

[sshd]
enabled = true
port = 2244
mode = aggressive
filter = sshd
logpath = /var/log/auth.log
maxretry = 3
findtime = 600
bantime = 86400

This configuration dictates that if an IP fails authentication 3 times within 10 minutes (600s), Fail2ban blocks all network packets from that IP for a full 24 hours (86,400s).

Step 4: Activating & Monitoring Fail2ban

Enable and start the Fail2ban service:

sudo systemctl enable --now fail2ban
sudo fail2ban-client status sshd

You can view the real-time list of currently banned malicious IP addresses:

sudo fail2ban-client status sshd
# Output displays:
# Currently failed: 0
# Total failed: 14
# Currently banned: 2
# Banned IP list: 185.220.101.42 194.26.29.112

Summary

By enforcing Ed25519 SSH keys, disabling password authentication, moving off port 22, and deploying Fail2ban, your Linux VPS on Hostinger or Contabo transforms from an easy target into a fortified fortress.

Video Walkthrough & Official References

Linux Server Security Tutorial: SSH, UFW Firewall & Fail2ban • DevOps Made Simple

Watch on YouTube

Editorial Verdict: Pros & Cons

What We Love (Pros)

  • Permanently halts automated dictionary attacks and password-guessing botnets
  • Ed25519 cryptographic SSH keys provide mathematical immunity against brute-force penetration
  • Fail2ban automatically writes dynamic firewall drop rules against repeat offenders

Drawbacks (Cons)

  • Improper configuration can lock you out; always maintain an active terminal session while testing
Viktor Chen

Written by Viktor Chen

Systems Performance Engineer

Alex and the ServerCraft engineering lab run routine benchmarks on over 25 web hosting providers, maintaining strict objectivity and reproducibility.

Recommended Next Reads