Home / Guides / VPS hardening checklist: secure a new Linux server in 15 minutes
Guide

VPS hardening checklist.

A fresh server is scanned within minutes of going online. These steps remove the easy wins for attackers.

1. Update and create a normal user

apt update && apt full-upgrade -y
adduser deploy
usermod -aG sudo deploy

2. SSH keys only

Keep a second session open when you reload SSH, so a mistake does not lock you out. The out-of-band console is your fallback.

# from your laptop
ssh-copy-id deploy@YOUR-SERVER-IP
# then on the server, in /etc/ssh/sshd_config.d/10-hardening.conf
PasswordAuthentication no
PermitRootLogin no
systemctl reload ssh

3. Firewall

Open further ports only for services you run.

apt install -y ufw
ufw default deny incoming
ufw default allow outgoing
ufw allow OpenSSH
ufw enable

4. Automatic security updates

apt install -y unattended-upgrades
dpkg-reconfigure -plow unattended-upgrades

5. Reduce what is running

List listening services with ss -tlnp and remove or bind to localhost anything you do not need.

6. Brute-force protection

With keys only, brute force cannot succeed, but fail2ban reduces log noise: apt install -y fail2ban.

7. Back up off the server

Use an encrypted backup tool to a different location. Test a restore. A backup you have not restored is a hope, not a backup.

Check your work

  1. Open a second terminal and confirm you can still log in before closing the first.
  2. Run ss -tulpn and check that only expected ports listen.
  3. Review /var/log/auth.log for failed attempts.
  4. Reboot once and confirm services return.

Keep going

Hardening is not a one-time task. Apply updates, review users and remove software you no longer use. For stored data, consider full-disk encryption.

FAQ

Common questions

Should I change the SSH port?

It reduces noise from scanners but adds no real security. Keys and a firewall do the work.

What should I do first on a new VPS?

Update packages, create a normal user, set up SSH keys and enable a firewall.

Should I disable root login?

Yes, once a normal user with sudo works.

How often should I update?

Enable automatic security updates and review the server regularly.

Keep reading

Related pages

Encrypt a VPS with LUKS and unlock it remotely over SSH

Step-by-step: full-disk encryption on a Debian or Ubuntu VPS with LUKS and dropbear in the initramfs for remote unlock.

Read more →

Host your own

Host your own apps on a private VPS: what size to choose for common self-hosted services, backups, updates and where to start.

Read more →

Your own VPN,

Why and how to host a personal VPN on a VPS: what it protects, what it does not, which plan to pick and a minimal WireGuard setup.

Read more →

Run a Tor onion service on a VPS

How to publish a website or admin panel as a Tor onion service on a VPS: install, configure, test and keep it private.

Read more →

SSH keys and fail2ban

Set up SSH key login, turn off password login and add fail2ban to a VPS. Copy-and-paste commands for Ubuntu 24.04.

Read more →

Docker Compose on a VPS

Install Docker and Docker Compose on a VPS, run an app, set restart policies and keep ports safe. Copy-and-paste commands for Ubuntu 24.04.

Read more →

Put it into practice on a VPS.

Open the configurator