Debian 13 on a 1 GB KVM box: the boring baseline
Every new small VPS gets the same treatment before anything useful runs on it. None of this is clever; it is the list I kept forgetting half of.
1. Update first, reboot once
Provider images are usually a few point releases behind, and the kernel update only counts after a reboot.
apt update && apt full-upgrade -y
ls /boot/vmlinuz-* # newer than `uname -r`? reboot
Check whether unattended-upgrades is already on before installing it again; most cloud images ship it enabled:
cat /etc/apt/apt.conf.d/20auto-upgrades
systemctl is-active unattended-upgrades
2. A small swapfile
1 GB of RAM and zero swap means the OOM killer picks a victim the first time Docker pulls a large image. A 1 GB swapfile with low swappiness is cheap insurance.
fallocate -l 1G /swapfile
chmod 600 /swapfile
mkswap /swapfile && swapon /swapfile
echo '/swapfile none swap sw 0 0' >> /etc/fstab
echo 'vm.swappiness = 10' > /etc/sysctl.d/99-swap.conf
3. BBR + fq
For long, lossy paths (anything crossing an ocean) BBR is noticeably better than cubic.
cat > /etc/sysctl.d/99-bbr.conf <<'EOF'
net.core.default_qdisc = fq
net.ipv4.tcp_congestion_control = bbr
EOF
echo tcp_bbr > /etc/modules-load.d/bbr.conf
modprobe tcp_bbr && sysctl --system
4. Turn off LLMNR
systemd-resolved listens on 0.0.0.0:5355 for LLMNR by default. On a server with a public address that is
just one more open port.
mkdir -p /etc/systemd/resolved.conf.d
printf '[Resolve]\nLLMNR=no\nMulticastDNS=no\n' > /etc/systemd/resolved.conf.d/no-llmnr.conf
systemctl restart systemd-resolved
ss -ulpn | grep 5355 # should print nothing
5. fail2ban on a non-standard SSH port
The Debian package enables the sshd jail out of the box (with the systemd backend on trixie, which is what
you want since there is no /var/log/auth.log). The catch: the jail bans port ssh, i.e. 22.
If sshd listens elsewhere, bans do nothing until you say so:
cat > /etc/fail2ban/jail.local <<'EOF'
[DEFAULT]
bantime = 1h
findtime = 10m
maxretry = 5
bantime.increment = true
[sshd]
port = 2222
EOF
systemctl restart fail2ban
fail2ban-client get sshd action nftables port
6. Make the hostname stick
If the image uses cloud-init, a hostname set with hostnamectl may be reverted on the next boot.
printf 'preserve_hostname: true\nmanage_etc_hosts: false\n' \
> /etc/cloud/cloud.cfg.d/99-keep-hostname.cfg
That is it. Docker, vnstat and the usual tools come after this, never before.