Every internet-facing Linux server is subjected to automated credential brute-force attempts within seconds of obtaining an IP address. Applying foundational hardening standards during initial provisioning is the single highest ROI security practice.
Step 1: Deploying Ed25519 Cryptographic SSH Keys
Ed25519 elliptic-curve public-key signatures provide superior performance and cryptographic resistance compared to legacy RSA 2048 keys. Generate a local key pair:
# Run on your local workstation
ssh-keygen -t ed25519 -C "admin@zozo.host"
ssh-copy-id -i ~/.ssh/id_ed25519.pub root@YOUR_SERVER_IP
Step 2: Hardening /etc/ssh/sshd_config
Disable password authentication, root password logins, and enforce SSH protocol 2:
# /etc/ssh/sshd_config.d/99-hardened.conf
Port 2222
PermitRootLogin prohibit-password
PasswordAuthentication no
ChallengeResponseAuthentication no
MaxAuthTries 3
ClientAliveInterval 300
ClientAliveCountMax 2
X11Forwarding no
Step 3: Stateful Firewall (UFW) Configuration
Enforce default deny incoming, enable connection rate limiting on SSH, and permit HTTP/HTTPS traffic:
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw limit 2222/tcp comment "Rate-limited SSH"
sudo ufw allow 80/tcp comment "HTTP Web"
sudo ufw allow 443/tcp comment "HTTPS TLS"
sudo ufw enable
Step 4: Automated Brute-Force Banning with Fail2ban
Install and configure fail2ban to continuously monitor auth logs and automatically drop repeat offender IP addresses via firewall rules.