IT Manager candidate based in Riyadh. 12+ years in IT operations and infrastructure.

Phone

+966 55 973 2392

Website

https://www.islamfathi.com

Address

Riyadh, Saudi Arabia

Social Links

Tutorials

Hardening a fresh Debian server in an afternoon

A short list that closes the easy ways in on a new Debian server: updates, SSH keys, a firewall, fewer open ports and fail2ban.

Hardening a fresh Debian server in an afternoon

A server with a public IP address gets probed within minutes of going online. Covering the basics takes an afternoon and a short list, and it removes most of the easy ways in.

Update, then automate updates

Bring the system up to date first, then let it install security updates on its own.

sudo apt update && sudo apt full-upgrade
sudo apt install unattended-upgrades
sudo dpkg-reconfigure -plow unattended-upgrades
Use a normal account and SSH keys

Create a regular user, add it to the sudo group and copy your public key to it. Open a second terminal and confirm you can log in with the key before changing anything else.

sudo adduser sysadmin
sudo usermod -aG sudo sysadmin
ssh-copy-id sysadmin@server

Then edit /etc/ssh/sshd_config and set PermitRootLogin no and PasswordAuthentication no. Check the file with sudo sshd -t and reload the service. Keep your first session open until the second one works, so a typo does not lock you out.

Turn on a firewall

ufw is the simplest option on Debian. Allow SSH before you enable it.

sudo apt install ufw
sudo ufw default deny incoming
sudo ufw allow 22/tcp
sudo ufw allow 80,443/tcp
sudo ufw enable
See what is listening

List the listening services and ask whether each one needs to be there.

sudo ss -tulpn

Anything you cannot explain should be removed or limited to localhost.

Add fail2ban and send logs away

fail2ban bans addresses that fail logins repeatedly. With key-only SSH it mostly reduces log noise, but it also covers other services you add later. Ship logs to a central place if you have one, since an attacker with root can edit local logs.

2 min read
Feb 09, 2026
By Islam Fathy
Share

Leave a comment

Your email address will not be published. Required fields are marked *

Related posts

Oct 06, 2026 • 1 min read
Automating Repetitive IT Tasks with PowerShell and C#

How small scripts and simple tools save IT teams hours every week, and where to start.

Sep 29, 2026 • 2 min read
SPF, DKIM and DMARC in plain terms

Three DNS records decide whether your email is trusted. What each one does, an example of each, and...

Aug 18, 2026 • 2 min read
DNS problems you can diagnose in five minutes

Many network is down tickets are DNS. A few commands and one question tell you whether the name or t...

Your experience on this site will be improved by allowing cookies. We use cookies to enhance performance and improve your browsing experience. Cookie Policy