Knowledge base Contact support
VPS servers

Secure your VPS

First steps to lock down a new Linux VPS: updates, SSH keys, a firewall and a non-root user.

Updated 1 min read

A VPS is fully yours, which means keeping it safe is too. Do these on day one.

1. Update the system

On Ubuntu or Debian:

sudo apt update && sudo apt upgrade -y

On AlmaLinux or Rocky Linux:

sudo dnf upgrade -y

2. Create a user for everyday work

adduser yourname
usermod -aG sudo yourname

On AlmaLinux or Rocky, use the wheel group instead of sudo.

3. Sign in with an SSH key

On your computer, create a key with ssh-keygen, then copy it to the server with ssh-copy-id [email protected]. Check you can log in with the key before the next step.

4. Turn off password and root logins

In /etc/ssh/sshd_config, set PasswordAuthentication no and PermitRootLogin no, then restart SSH.

Keep a session open while you test the new settings in a second window. If something's wrong, you can still fix it.

5. Turn on a firewall

Allow only what you use, such as SSH, HTTP and HTTPS. On Ubuntu: sudo ufw allow OpenSSH, sudo ufw allow 80,443/tcp, then sudo ufw enable.

If your server has cPanel and WHM, its security tools cover much of this. See WHM's Security Center.

Was this guide helpful?

Still stuck? Contact support and tell us what you tried.