What should I secure before my first VPS deployment?
Update the system, create a user, protect SSH, enable the firewall and backups. Security on a VPS with root access is your responsibility.
Security on a VPS with root access is your responsibility. Complete these steps before exposing an application or a database.
Step-by-step procedure
-
Update the system
Install security updates at first login.
-
Create an administrator
Create a personal user, add it to sudo and test a second session before changing the root account.
-
Install the SSH key
Confirm that key-based login works, then disable SSH password authentication once you have a backup way to access the server.
-
Configure UFW
Allow SSH before enabling the firewall, then open only the ports you need.
-
Enable Fail2ban and backups
Monitor attempts, keep backups outside the VM, and test a restore.
Debian baseline
apt update && apt full-upgrade -y
apt install -y ufw fail2ban
ufw allow OpenSSH
ufw enable
systemctl enable --now fail2ban
Turn off SSH password login
sed -i -e 's/^PasswordAuthentication yes/PasswordAuthentication no/' \
-e 's/^PermitRootLogin yes/PermitRootLogin prohibit-password/' \
/etc/ssh/sshd_config.d/00-aclclouds-password-access.conf
sshd -t && systemctl reload ssh
sshd -T | grep -Ei 'passwordauthentication|permitrootlogin'
Fail2ban with the systemd journal
printf '[sshd]\nbackend = systemd\n' > /etc/fail2ban/jail.local
systemctl restart fail2ban
fail2ban-client status sshd
Before you start
Keep two SSH sessions open: one for changes, the other as a fallback. If a setting locks you out, the "noVNC console" on the VPS page still gives access to the VM screen, even without a network.
- Your public key is installed and a key-based login has been tested.
- The qemu-guest-agent package stays installed and running: "Change password", "Rescue restart" and the panel "Shell" tool depend on it.
- On Fedora and CentOS Stream, the administrator group is called wheel, not sudo.
Turn off password access
On delivery, ACLClouds enables password login so that the credentials sent by email work. This setting is written to /etc/ssh/sshd_config.d/00-aclclouds-password-access.conf, which is read before /etc/ssh/sshd_config. OpenSSH keeps the first value it reads, so editing only sshd_config is not enough.
In this file, replace PasswordAuthentication yes with PasswordAuthentication no and PermitRootLogin yes with PermitRootLogin prohibit-password, or with no if you work with a sudo user. Validate with sshd -t, reload the service, then test a new connection before closing the old one.
"Change password" and "Rescue restart" rewrite this file and turn password login back on: after using them, apply this setting again.
Check that everything works
sshd -T | grep -i passwordauthentication should answer passwordauthentication no. ufw status verbose should show Status: active and the SSH rule as ALLOW. fail2ban-client status sshd should list the sshd jail with an attempt counter.
Keep a console open
Test SSH in a second window before closing the current session or disabling password authentication.
Frequently asked questions
Fail2ban does not start and shows Have not found any log file for sshd jail, what should I do?
The system logs SSH to the systemd journal and the file /var/log/auth.log does not exist, which is common on Debian 12. Create /etc/fail2ban/jail.local with an [sshd] section containing backend = systemd (see the block below), then restart Fail2ban.
My Docker ports are still reachable despite UFW, is that normal?
Yes. Docker writes its own iptables rules, and a port published with -p takes precedence over UFW rules. Publish an internal service on the loopback (-p 127.0.0.1:8080:80) or filter it with the panel "Firewall", applied outside the VM once "Firewall enabled" is on in "Firewall options".
How do I install security fixes automatically?
On Debian and Ubuntu, install unattended-upgrades and enable it with dpkg-reconfigure -plow unattended-upgrades. Security fixes are then applied every day.