Linux & DevOps Ubuntu 24.04 LTS

Hardening SSH and Configuring UFW Firewall on Ubuntu 24.04 LTS

A checklist and implementation guide for securing an Ubuntu server: Ed25519 keys, password authentication disablement, and UFW rate limiting.
Z
Zaisha
Staff Writer · Verified Editor
Published Oct 23, 2026 · 3 min read · 249 words
Quick Overview

This deep-dive covers hardening ssh ufw firewall with actionable analysis, practical implications, and expert insights.

Hardening SSH and Configuring UFW Firewall on Ubuntu 24.04 LTS

Why Server Hardening Is the First Priority

Publicly reachable Linux servers are scanned by automated botnets within minutes of receiving an IP address. Leaving password authentication enabled on default SSH ports invites brute-force credential stuffing. Here is the verified hardening sequence for Ubuntu.

Step 1: Generate an Ed25519 SSH Key Pair

On your local computer (not the server), generate an Ed25519 key pair with a passphrase:

ssh-keygen -t ed25519 -C "admin@newssparx"

Copy your public key to the remote Ubuntu server:

ssh-copy-id -i ~/.ssh/id_ed25519.pub user@your-server-ip

Step 2: Hardening sshd_config

Connect to the server and edit the SSH configuration at /etc/ssh/sshd_config.d/50-cloud-init.conf or /etc/ssh/sshd_config:

# Disable root login over SSH
PermitRootLogin no

# Enforce public key authentication only
PasswordAuthentication no
PubkeyAuthentication yes

# Disable empty passwords
PermitEmptyPasswords no

# Limit maximum authentication tries
MaxAuthTries 3

Test the SSH syntax before restarting the daemon to prevent lockouts:

sudo sshd -t && sudo systemctl restart ssh

Step 3: Configuring the UFW Firewall

Configure Uncomplicated Firewall (UFW) with strict defaults:

# Set default policies: block incoming, allow outgoing
sudo ufw default deny incoming
sudo ufw default allow outgoing

# Allow and rate-limit SSH connections
sudo ufw limit 22/tcp comment "Rate-limited SSH"

# Allow web traffic if hosting public services
sudo ufw allow 80/tcp comment "HTTP"
sudo ufw allow 443/tcp comment "HTTPS"

# Enable the firewall
sudo ufw enable
sudo ufw status verbose

Keep your current SSH window open and test connecting from a second terminal window to verify successful key-based login.

Tested & Verified Environment
Author Verified
Operating System: Ubuntu 24.04 LTS
Verification Date: Oct 23, 2026
Testing Methodology & Notes: Tested on cloud instance running Ubuntu 24.04 LTS. Tested SSH Ed25519 login, password authentication denial, and UFW rate limiting on port 22.

Was this technical analysis helpful?

Your feedback informs our benchmark updates and ongoing article audits.

✓ Thank you for your feedback! Our editorial engineers review submissions weekly.

Frequently Asked Questions

Structured for search engines and AI answer systems (AEO/GEO).

Ed25519 provides superior security resistance, faster signature calculations, and shorter key lengths compared to legacy RSA algorithms.

Not if you allow port 22 (sudo ufw allow 22/tcp) before running sudo ufw enable.

The ufw limit 22/tcp command automatically denies connections from an IP that initiates 6 or more connections within 30 seconds.

More answers in our FAQ hub.

Z
Zaisha

Tech journalist covering AI, software, and emerging technology with a focus on practical insights.

Testing Standards: Tutorials and guides are hands-on tested on Ubuntu Linux workstations before release.
View all articles by Zaisha

Practical Linux & Applied AI Newsletter

Get new tested tutorials and benchmark comparisons delivered directly to your inbox. Zero spam.

Join Weekly guides readers getting our weekly digest.

  • Practical Linux administration & terminal workflows
  • Tested open-source AI setups & benchmarks
  • Zero spam - unsubscribe anytime

Join Weekly guides readers · Weekly digest · Unsubscribe anytime. RSS

Continue Exploring