Automatic Security Updates with Unattended Upgrades
Most compromised servers weren't hacked with anything clever — they were simply never updated. On Ubuntu and Debian, unattended-upgrades installs security fixes for you, every day.
Install and enable
apt update && apt install -y unattended-upgrades
dpkg-reconfigure -plow unattended-upgrades
Answer Yes. That's enough to start receiving security updates automatically.
What it updates
By default only packages from the security repository. Feature updates stay manual, which keeps surprises to a minimum. The settings live in /etc/apt/apt.conf.d/50unattended-upgrades.
Reboots
Kernel updates only take effect after a reboot. You can let the server reboot itself at a quiet time:
Unattended-Upgrade::Automatic-Reboot "true";
Unattended-Upgrade::Automatic-Reboot-Time "04:00";
Only turn this on if your services start on boot — systemd units, Docker containers with a restart policy. Otherwise check for a pending reboot now and then:
ls /var/run/reboot-required
Check that it works
Run a dry run:
unattended-upgrade --dry-run --debug
And see what it did recently:
cat /var/log/unattended-upgrades/unattended-upgrades.log
What it doesn't cover
- Docker images — update them with docker compose pull.
- Apps you installed by hand — Node via nvm, binaries in /usr/local.
- Major OS upgrades — those stay a deliberate, manual step.
Five minutes, once
Set it up when you deploy and the most common way servers get compromised is off the table.
Deploy a server and patch it on autopilot.