- The Reality of Production Server Attacks
- Server Hardening Defense Hierarchy
- Step 1: Hardening the SSH Daemon
- Step 2: Configuring UFW (Uncomplicated Firewall)
- Step 3: Deploying Fail2ban Against Brute-Force Attacks
- Step 4: Automated Security Upgrades
- Frequently Asked Questions (FAQ)
- Related Architectural Deep Dives
The Reality of Production Server Attacks
Within seconds of provisioning a new virtual private server (VPS) with a public IPv4 address on AWS, DigitalOcean, or Hetzner, automated botnets begin probing your machine. Hundreds of automated SSH brute-force attempts per minute test default credentials (root:root, admin:admin) and scan for unpatched vulnerabilities.
Securing a production Linux host does not require enterprise security software. Applying the principle of least privilege, disabling password-based authentication, configuring a stateful firewall with UFW, and deploying automated brute-force banning with Fail2ban eliminates 99.9% of automated attack vectors.
In this operational guide, we execute a complete baseline security hardening checklist for Ubuntu 24.04 LTS servers.
Server Hardening Defense Hierarchy
Multi-Layer Defense Architecture:
┌────────────────────────────────────────────────────────┐
│ 1. UFW Firewall: Drop all traffic except 22, 80, 443 │
└───────────────────────────┬────────────────────────────┘
▼
┌────────────────────────────────────────────────────────┐
│ 2. Fail2ban: Ban IP for 24h after 3 failed attempts │
└───────────────────────────┬────────────────────────────┘
▼
┌────────────────────────────────────────────────────────┐
│ 3. SSH Hardening: Disable Root, Ed25519 Keys Only │
└───────────────────────────┬────────────────────────────┘
▼
┌────────────────────────────────────────────────────────┐
│ 4. Unattended Upgrades: Auto-apply security kernel CVEs│
└────────────────────────────────────────────────────────┘Step 1: Hardening the SSH Daemon
Always generate modern Ed25519 elliptic-curve keys rather than legacy RSA keys. On your local terminal:
# Generate secure Ed25519 keypair
ssh-keygen -t ed25519 -C "admin@techaventure.co.in"On the server, edit /etc/ssh/sshd_config.d/hardening.conf:
# /etc/ssh/sshd_config.d/hardening.conf
Port 22
PermitRootLogin no
PasswordAuthentication no
KbdInteractiveAuthentication no
PubkeyAuthentication yes
X11Forwarding no
MaxAuthTries 3
ClientAliveInterval 300
ClientAliveCountMax 2
# Validate syntax before restarting!
sshd -t && systemctl restart sshStep 2: Configuring UFW (Uncomplicated Firewall)
UFW is a stateful frontend for iptables/nftables. Set a default deny policy and explicitly open only necessary web ports:
# Set default security policies
sudo ufw default deny incoming
sudo ufw default allow outgoing
# Allow essential services
sudo ufw allow 22/tcp comment 'SSH Access'
sudo ufw allow 80/tcp comment 'HTTP Web'
sudo ufw allow 443/tcp comment 'HTTPS Web'
# Enable firewall
sudo ufw enable
sudo ufw status verboseStep 3: Deploying Fail2ban Against Brute-Force Attacks
Fail2ban monitors auth logs and dynamically adds temporary firewall drop rules for offending IP addresses:
sudo apt update && sudo apt install -y fail2banCreate a custom jail configuration in /etc/fail2ban/jail.local:
[DEFAULT]
bantime = 1d
findtime = 10m
maxretry = 3
backend = systemd
[sshd]
enabled = true
port = ssh
filter = sshd
maxretry = 3
sudo systemctl restart fail2ban
sudo fail2ban-client status sshdStep 4: Automated Security Upgrades
Ensure critical Linux kernel and OpenSSL CVE patches install automatically without manual intervention:
sudo apt install -y unattended-upgrades
sudo dpkg-reconfigure -plow unattended-upgradesFrequently Asked Questions (FAQ)
Does changing the default SSH port (e.g. to 2222) improve security?
Changing the SSH port is security through obscurity; it does not stop targeted port scans with Nmap. However, it does eliminate ~95% of automated scripted noise from basic scanning bots, keeping your auth log files clean.
Can Fail2ban lock me out of my own server?
Yes, if you enter an invalid password or key multiple times. Always add your office or home static IP to the whitelist in /etc/fail2ban/jail.local under ignoreip = 127.0.0.1/8 ::1 YOUR_STATIC_IP.
Related Architectural Deep Dives
Continue expanding your technical depth with our related engineering guides:
- JavaScript Event Loop Architecture: Execution phases, microtask queues, and worker thread concurrency. Explore the complete guide: JavaScript Event Loop Architecture.
- JavaScript Memory Leaks & DevTools Profiling: Heap snapshot allocation analysis, closure retention, and detached DOM fixes. Explore the complete guide: JavaScript Memory Leaks & DevTools Profiling.
Published by Mohit Kumar under DevOps & Cloud Infrastructure. Read our server setup guide on Nginx Reverse Proxy & SSL Hardening with Let’s Encrypt.



