A fresh Debian server is quiet, fast and almost empty. That is the point, but it also means the first 20 minutes decide whether it stays a clean, safe machine or turns into the box that got brute-forced over the weekend.
This is the checklist I run on every new Debian VPS, written for Debian 13 (trixie), the current stable release. Most of it applies to Debian 12 as well, and I call out the places where trixie behaves differently, because a few of those changes catch people out on small servers.
It assumes a plain Debian image on a KVM VPS with root access, the kind you get from most providers, including VPS Shell. Nothing here depends on a specific host.
1. Look at what you actually got
Before changing anything, spend 30 seconds confirming the basics:
cat /etc/debian_version hostnamectl free -h df -h / ip -br a You want to see the Debian version you ordered, the RAM and disk you paid for, and your public IP on the main interface. If any of that is off, raise it with your provider now, not after you have deployed an app.
2. Update everything, then reboot once
apt update apt full-upgrade -y Provider images are often a few weeks old. If the upgrade pulled in a new kernel, reboot so you are actually running it:
reboot Doing this on day one is painless. Doing it later, with services running, is the reboot everyone keeps postponing.
3. Hostname, time zone and time sync
Give the machine a name you will recognise in logs and prompts:
hostnamectl set-hostname web-01 Set the time zone. Many people keep servers on UTC so logs line up across machines:
timedatectl set-timezone UTC timedatectl Check that System clock synchronized says yes. Some minimal images ship without a time sync service. If it says no, install the lightweight one Debian provides:
apt install -y systemd-timesyncd Wrong time breaks TLS, two-factor codes and log correlation in confusing ways, so this is worth getting right early.
4. Fix locale warnings before they annoy you
If you SSH in from a Mac or a desktop set to another language, you may see setlocale warnings on every command. Generate the locale your client sends, or set a sensible default:
dpkg-reconfigure locales Pick en_US.UTF-8 (plus any locale you actually use) and set it as the default.
5. Create your own user with sudo
Working as root all the time makes every typo a full-power typo. Minimal Debian images do not always include sudo, so install it first:
apt install -y sudo adduser alex usermod -aG sudo alex Open a second terminal and confirm you can log in as that user and run sudo whoami before you go further. Keep your root session open until then.
6. Switch SSH to keys only
On your own computer, create a modern key if you do not have one. Ed25519 is short, fast and widely supported:
ssh-keygen -t ed25519 -C "alex@laptop" ssh-copy-id alex@YOUR_SERVER_IP One Debian 13 detail: OpenSSH in trixie has dropped DSA completely. According to the release notes, as of OpenSSH 9.8p1 in trixie, DSA keys are no longer supported even with the old compatibility options. If you still have an ancient id_dsa key somewhere, replace it now.
Rather than editing the main config file, put your changes in a drop-in file, which survives package upgrades cleanly:
sudo nano /etc/ssh/sshd_config.d/10-hardening.conf PasswordAuthentication no KbdInteractiveAuthentication no PermitRootLogin no Test the configuration before applying it, then reload:
sudo sshd -t && sudo systemctl reload ssh Note that the service is called ssh on Debian, not sshd. Now, without closing your current session, open a new terminal and log in with your key. Only close the old session once the new one works. This one habit prevents most self-inflicted lockouts.
7. Turn on a simple firewall
Debian uses nftables under the hood, but for a single server ufw is the easiest way to get a safe default:
sudo apt install -y ufw sudo ufw default deny incoming sudo ufw default allow outgoing sudo ufw allow OpenSSH sudo ufw enable sudo ufw status verbose The order matters: allow SSH before you enable the firewall. Add web ports only when you actually run a web server:
sudo ufw allow 80,443/tcp 8. Let security updates install themselves
Most servers are not compromised through clever zero-days. They are compromised through old, known bugs that a routine update would have fixed. Debian's unattended-upgrades handles security updates on its own:
sudo apt install -y unattended-upgrades apt-listchanges sudo dpkg-reconfigure -plow unattended-upgrades Answer yes. By default it only installs updates from the security archive, which is the safe choice for a server. Check that it would do something sensible:
sudo unattended-upgrade --dry-run --debug 9. Add swap on small servers
A 1 GB or 2 GB VPS with no swap will eventually meet the out-of-memory killer, usually during a package upgrade or a build. A small swap file gives you breathing room:
sudo fallocate -l 1G /swapfile sudo chmod 600 /swapfile sudo mkswap /swapfile sudo swapon /swapfile echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab Tell the kernel to prefer RAM and use swap only when it has to:
echo 'vm.swappiness=10' | sudo tee /etc/sysctl.d/99-swappiness.conf sudo sysctl --system 10. Know the Debian 13 changes that surprise people
A few trixie changes are harmless on a laptop but matter on a small server.
/tmp now lives in RAM. On trixie, the default is for the /tmp directory to be stored in memory, and up to 50% of memory can be allocated to it. On a 1 GB VPS, a big upload or a build that writes large temp files can eat into the memory your apps need. If that is a problem, cap it with sudo systemctl edit tmp.mount and set a size in the options, for example Options=mode=1777,nosuid,nodev,size=256M.
/tmp and /var/tmp are cleaned automatically. Files in /tmp are now deleted after 10 days from the time they were last used, and after a reboot. Files in /var/tmp are deleted after 30 days, but not after a reboot. Never keep anything you care about in either place.
last and lastlog are gone. util-linux no longer provides the last or lastb commands, and the login package no longer provides lastlog. If you rely on them to check who logged in, install the replacements: wtmpdb (with libpam-wtmpdb) replaces last, and lastlog2 (with libpam-lastlog2) replaces lastlog. For failed logins, lslogins --failed gives similar information to lastb. And journalctl -u ssh always works.
11. Optional: fail2ban, configured for the journal
With password logins disabled, brute-force attempts cannot succeed, but they still fill your logs. fail2ban bans noisy IPs. On recent Debian, SSH logs go to the systemd journal rather than a text file, so tell fail2ban to read the journal:
sudo apt install -y fail2ban sudo nano /etc/fail2ban/jail.d/sshd.local [sshd] enabled = true backend = systemd maxretry = 5 bantime = 1h sudo systemctl restart fail2ban sudo fail2ban-client status sshd If fail2ban fails to start complaining about a missing log file, the backend = systemd line is usually what is missing.
12. Take a snapshot before you build anything
You now have a clean, updated, locked-down base. If your provider offers snapshots or backups, take one now. It is the fastest way back to a known-good server if an experiment goes wrong later.
The 20-minute checklist
- Confirm Debian version, RAM, disk and IP
-
apt full-upgrade, reboot once - Hostname, time zone, time sync
- Locale set, no
setlocalewarnings - Personal user with sudo, root login disabled
- SSH keys only, config in
sshd_config.d, tested before closing your session - ufw on, SSH allowed first
- unattended-upgrades for security updates
- Swap on small servers
- Aware of tmpfs
/tmp, auto-cleaning, and thelastreplacements - fail2ban with
backend = systemdif you want quieter logs - Snapshot taken
That is the whole routine. It is not exotic, and that is exactly why it works: a server that is updated, key-only and firewalled already avoids the vast majority of trouble that new VPS owners run into. If you do something different on your own first boot, I would like to hear about it in the comments.

