The First Hour on a New Ubuntu Server: A Hardening Checklist
A practical, ordered checklist for securing a fresh Ubuntu LTS server before you deploy anything to it.
By DevOpsCommand Engineering · · 2 min read

Most server compromises we investigate do not involve exotic exploits. They involve password logins left enabled, services exposed that nobody meant to expose, and patches that were never applied. The good news is that the first hour on a new server is enough to close most of those doors.
This checklist assumes a fresh Ubuntu 24.04 LTS VPS and that you are connected as root or a sudo user. Run each step in order and keep your current SSH session open until you have confirmed you can log in again.
1. Update everything
sudo apt update && sudo apt full-upgrade -y
sudo reboot
Images are often weeks old. Apply outstanding updates before doing anything else, and reboot if the kernel was upgraded.
2. Create a non-root administrator
sudo adduser deploy
sudo usermod -aG sudo deploy
3. Use SSH keys, then disable password logins
From your workstation, copy your public key to the new user:
ssh-copy-id deploy@your-server-ip
Confirm you can log in with the key in a new terminal. Then create a drop-in configuration file rather than editing the main file:
# /etc/ssh/sshd_config.d/10-hardening.conf
PermitRootLogin no
PasswordAuthentication no
KbdInteractiveAuthentication no
PubkeyAuthentication yes
sudo sshd -t && sudo systemctl reload ssh
sshd -t validates the configuration before you reload, so a typo cannot lock you out.
4. Turn on the firewall
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow OpenSSH
sudo ufw allow 80,443/tcp
sudo ufw enable
Only open what the server actually needs. Databases should almost never be reachable from the internet; bind them to 127.0.0.1 or a private network.
5. Enable automatic security updates
sudo apt install -y unattended-upgrades
sudo dpkg-reconfigure -plow unattended-upgrades
6. Slow down brute-force attempts
sudo apt install -y fail2ban
sudo systemctl enable --now fail2ban
With password authentication disabled, brute force cannot succeed, but fail2ban keeps logs quieter and blocks noisy scanners.
7. Check what is listening
sudo ss -tulpn
Every listening port should be one you can explain. Disable or uninstall anything you cannot.
8. Set up off-server backups before you need them
A backup stored on the same server is not a backup. Use a tool such as restic to push encrypted backups to object storage, and test a restore before going live.
What this checklist does not cover
Application-level security, TLS configuration, log shipping and intrusion detection all matter too, and depend on what you run. If you would rather have this done and maintained for you, our VPS Security Hardening and Managed VPS services cover it end to end.