On a VPS server, updates and the firewall are your responsibility: we don't change anything on the server after handing it over to you. The good news is that both are set up once and then run on their own. This guide assumes you log in with your own user, with sudo (see Your VPS server: a regular user and key-only SSH).
What you'll achieve
- bring the system up to date;
- turn on automatic security updates;
- leave open only the ports you use.
Before you start
- If you have more than a blank server you've just received, ask us for a snapshot first (by email or WhatsApp; we take it the same business day). The snapshots in your plan are included in the price.
- You know what runs on the server and on which ports: SSH on 22, a website on 80 and 443, n8n or other apps on their own ports.
- Keep an SSH session open while you configure the firewall. If you accidentally block SSH, you can fix it from there.
The steps
A. Bring the system up to date
- Ubuntu and Debian:
sudo apt update && sudo apt upgrade - AlmaLinux and Rocky:
sudo dnf upgrade - Check whether a reboot is needed (for example after a new kernel):
- Ubuntu and Debian: if the file
/var/run/reboot-requiredexists, reboot; - AlmaLinux and Rocky:
sudo dnf install dnf-utils, thensudo needs-restarting -r.
- Ubuntu and Debian: if the file
- Reboot with
sudo reboot, wait a minute and log in again.
B. Turn on automatic security updates
Ubuntu: the
unattended-upgradespackage is usually installed and enabled. Check:sudo dpkg-reconfigure -plow unattended-upgradesAnswer Yes. From now on, security updates install themselves, daily.
- Debian:
sudo apt install unattended-upgrades sudo dpkg-reconfigure -plow unattended-upgrades AlmaLinux and Rocky:
sudo dnf install dnf-automaticIn
/etc/dnf/automatic.conf, in the[commands]section, setapply_updates = yes(and, if you only want security updates,upgrade_type = security). Then:sudo systemctl enable --now dnf-automatic.timer- Automatic updates don't reboot the server. Once a month, or when you read about a major vulnerability, check step 3 and reboot at a quiet time.
C. Turn on the firewall — Ubuntu and Debian (UFW)
- On Debian, install it:
sudo apt install ufw. On Ubuntu it is already installed. Allow SSH first, or you will lock yourself out:
sudo ufw allow OpenSSHIf you moved SSH to another port, allow that port:
sudo ufw allow 2222/tcp.- Allow whatever else you use, for example a website:
sudo ufw allow 80/tcp sudo ufw allow 443/tcp Turn on the firewall and check:
sudo ufw enable sudo ufw status verboseBy default, UFW blocks all incoming traffic that isn't allowed and lets all outgoing traffic through.
D. Turn on the firewall — AlmaLinux and Rocky (firewalld)
- Make sure it is running:
sudo systemctl enable --now firewalld. - SSH is usually allowed from installation. Check and add what you use:
sudo firewall-cmd --permanent --add-service=ssh sudo firewall-cmd --permanent --add-service=http sudo firewall-cmd --permanent --add-service=https sudo firewall-cmd --reload sudo firewall-cmd --list-all
E. Check from outside
- From a new window, log in again over SSH. If it works, the firewall is fine.
- Open your public services in the browser (the website, the app's dashboard) and check that they load.
- See which ports are listening on the server:
sudo ss -tulpn. Any service listening on0.0.0.0or[::]that doesn't need to be public (a database, Redis) should either be stopped, bound only to127.0.0.1, or left blocked in the firewall.
Watch out for Docker
If you chose the image with Docker, n8n, Dokploy or another app that runs in containers, Docker creates its own network rules and bypasses UFW: a port published by a container (for example with -p 5678:5678) is reachable from the internet even if UFW doesn't allow it. To keep a container from being public, publish the port only locally (-p 127.0.0.1:5678:5678) and put a web server with HTTPS in front of it, or use the firewall rules from the Docker documentation.
If something doesn't work
- After
ufw enableyou can no longer log in over SSH. You didn't allow SSH or its port. From the session you kept open:sudo ufw allow OpenSSH(or your port). If you no longer have any session open, write to us: we will tell you your options, for example restoring from a snapshot. apt upgradeasks something about a configuration file. If you haven't modified the file, choose the package version (install the package maintainer's version); if you have modified it, keep yours.- A website or app stops responding after the firewall is on. Its port isn't allowed. Add it (steps 11 or 14).
- Uptime monitoring says the website isn't responding. Our bot checks from outside, like any visitor; the website's port must be open in the firewall (see Your VPS server: backups and monitoring).
