Knowledgebase article

How to secure your new Linux server (first 30 minutes)

A server straight out of the box is like a new house with the doors open. Before you move anything in, spend half an hour locking up. This guide is for Unmanaged Servers; on Managed Servers, Romeo does this for you.

1. Update everything

# AlmaLinux / Rocky / CentOS
dnf update -y

# Ubuntu / Debian
apt update && apt upgrade -y

2. Create your own user

Don't work as root every day.

adduser romeo
passwd romeo
usermod -aG wheel romeo     # AlmaLinux/Rocky
usermod -aG sudo romeo      # Ubuntu/Debian

3. Log in with SSH keys

On your computer, create a key and copy it to the server:

ssh-keygen -t ed25519
ssh-copy-id romeo@your-server-ip

Test that ssh romeo@your-server-ip works before the next step.

4. Turn off password and root login

Edit /etc/ssh/sshd_config and set:

PermitRootLogin no
PasswordAuthentication no

Then restart SSH: systemctl restart sshd.

Keep your current session open while you test a new login in a second window, so you can't lock yourself out.

5. Turn on a firewall

AlmaLinux / Rocky:

systemctl enable --now firewalld
firewall-cmd --permanent --add-service=ssh --add-service=http --add-service=https
firewall-cmd --reload

Ubuntu:

ufw allow OpenSSH
ufw allow 80,443/tcp
ufw enable

6. Block password guessers

Install Fail2ban, which bans IPs that fail to log in too often:

dnf install epel-release -y && dnf install fail2ban -y   # AlmaLinux/Rocky
apt install fail2ban -y                                  # Ubuntu/Debian
systemctl enable --now fail2ban

7. Keep it updated automatically

Turn on automatic security updates (dnf-automatic on AlmaLinux/Rocky, unattended-upgrades on Ubuntu).

Locked out by mistake? Open a ticket, and Romeo can help through the console.

Was this answer helpful?

Related articles

Still stuck? Romeo's got you.
Our support team replies around the clock, real humans who know your server.