Secure Your VPS
Basic hardening steps for a new Linux or Windows Server VPS.
Security is your responsibility
The infrastructure provider filters network attacks, see Anti-DDoS. The operating system, its updates, its firewall and everything you install on it are yours to secure. This page is general guidance, not a complete security programme, and it is not a guarantee of protection.
A new VPS has a public IP address and is found by automated scanners within minutes. Do the steps below soon after your first login.
1. Keep the system updated
Update the package lists and install all pending updates:
apt update && apt full-upgradeIf the update installs a new kernel, restart the server afterwards. To install security updates automatically:
apt install unattended-upgrades
dpkg-reconfigure -plow unattended-upgradesUnattended upgrades do not remove the need to check the server from time to time.
2. Use SSH keys, not passwords
On Linux, log in with SSH keys and turn off password login. Bots constantly try common passwords against root. On any system, use a long, unique password, see Change the VPS password.
3. Turn on a firewall
Only open the ports you use. A firewall blocks everything else, including services you did not mean to expose.
ufw is not installed on the Ubuntu 24.04 template, so install it first. Allow SSH before you enable the firewall, otherwise you will lock yourself out of your own session.
apt install ufw
ufw allow OpenSSH
ufw enable
ufw status verboseThen open only what your services need, for example a web server:
ufw allow 80/tcp
ufw allow 443/tcpIf you do get locked out, use the VNC console to fix the rules.
4. Protect Remote Desktop (Windows)
RDP on its public default port is attacked constantly. At least:
- use a long, unique
Administratorpassword; - keep Network Level Authentication enabled;
- in Windows Defender Firewall, limit the inbound RDP rule to the IP addresses you connect from (the rule's Scope tab, Remote IP address);
- keep Windows updated.
5. Block repeated login attempts (Linux)
fail2ban reads the logs and temporarily bans IP addresses that keep failing to log in.
apt install fail2ban
systemctl enable --now fail2ban
fail2ban-client status sshdThe default configuration already protects SSH. To change the settings, create /etc/fail2ban/jail.local instead of editing the shipped files. Fail2ban complements SSH keys and a firewall, it does not replace them.
6. Do not run services as root
Create a normal user for your applications and run them with that user, so that a vulnerability in an application does not give an attacker full control of the server.
adduser appuserFor administration, you can give a user sudo rights with usermod -aG sudo appuser and use that user for daily work.
7. Install only what you need
Every service you install is a potential entry point. Remove software you do not use, and keep the applications that you do use, and their plugins, up to date.
8. Keep backups
Backups are your responsibility. VPS plans do not give you a button to create backups or snapshots, see Backups.
Useful checks
ss -tulpn # which services listen on which ports
last -a | head # recent logins
ufw status verbose # firewall rulesIf you suspect that your server was compromised, do not keep using it. Copy out the data you need, then reinstall the OS and contact support if you need help.
