serverslot.com
ServerSlotServerSlot

Knowledgebase / Linux VPS

First steps to secure a new Linux VPS

A new server is on the internet from the first minute, so take these steps before anything else. The commands are for Ubuntu and Debian; on AlmaLinux or Rocky Linux use dnf instead of apt.

1. Install updates

apt update && apt upgrade -y

2. Use a strong password, or better, an SSH key

Run passwd to change the root password. To use a key, run ssh-keygen on your own computer, then ssh-copy-id root@your-server-ip. Once the key works you can turn off password sign-in in /etc/ssh/sshd_config (set PasswordAuthentication no) and restart SSH with systemctl restart ssh.

3. Turn on a firewall

Allow SSH first so you do not lock yourself out, then any other ports you need:

apt install ufw -y
ufw allow 22/tcp
ufw allow 80/tcp
ufw allow 443/tcp
ufw enable

4. Block repeated sign-in attempts

apt install fail2ban -y

The default settings already protect SSH.

5. Keep backups

Copy important files and databases off the server regularly. If you lock yourself out, open a ticket and we can help.

firewall linux security ssh keys ufw updates

Was this article helpful?

1 of 1 people found this helpful.