Rocky Linux VPS Setup Guide
Build a clean Rocky Linux baseline with CRB, audited logins and repeatable steps you can apply to every server.
People often choose Rocky Linux to run many matching servers. So beyond securing one machine, this guide builds a baseline that is easy to repeat.
- Works on: Rocky Linux 10, 9 and 8
- Recommended server: 2 GB of RAM or more
- Note: Rocky Linux 10 requires an x86-64-v3 capable CPU
Select your version
Choose Rocky Linux at checkout. Keep all servers in a group on the same major version so that your automation behaves the same on each.
Connect and record the baseline
Note the exact release and kernel, which helps when comparing servers later.
ssh root@YOUR_SERVER_IP
cat /etc/rocky-release
uname -rApply all updates
Start every server from a fully patched state.
dnf upgrade -y
systemctl rebootEnable CRB and EPEL
CRB is called PowerTools on Rocky Linux 8, so use powertools there instead.
dnf install dnf-plugins-core epel-release -y
dnf config-manager --set-enabled crb
dnf repolistCreate a named sudo user
Use the same username on every server to keep automation simple.
useradd -m -G wheel deploy
passwd deploy
# on your own computer
ssh-copy-id deploy@YOUR_SERVER_IPApply your SSH policy
Keeping policy in its own small file makes it easy to copy to other servers.
Test a new login before closing your current session. On version 8, this folder is not read, so set PermitRootLogin no and PasswordAuthentication no in /etc/ssh/sshd_config instead.
sudo tee /etc/ssh/sshd_config.d/10-hardening.conf > /dev/null <<'EOF'
PermitRootLogin no
PasswordAuthentication no
MaxAuthTries 3
EOF
sudo sshd -t && sudo systemctl restart sshdAllow only the services you run
Start firewalld, then see exactly what is exposed.
sudo dnf install firewalld -y
sudo systemctl enable --now firewalld
sudo firewall-cmd --permanent --add-service=ssh
sudo firewall-cmd --reload
sudo ss -tulpnPatch automatically
Limit automatic updates to security fixes if you prefer to control other changes yourself.
sudo dnf install dnf-automatic -y
sudo sed -i 's/^upgrade_type.*/upgrade_type = security/; s/^apply_updates.*/apply_updates = yes/' /etc/dnf/automatic.conf
sudo systemctl enable --now dnf-automatic.timerMake it repeatable
Once one server is right, turn these steps into something you can run again:
- Copy this baseline into an Ansible playbook
- Keep the playbook in version control
- Run it against every new server, so they all match
- Audit services periodically with ss -tulpn and systemctl list-unit-files
Get a server for this guide
Rocky Linux plans run everything in this guide, from $10.99/mo.
See Rocky Linux plansRocky Linux VPS Setup Guide: Frequently Asked Questions
Quick answers to common questions.
How do I build a repeatable Rocky Linux server baseline?
Get one Rocky Linux server right first: fully patched, CRB and EPEL enabled, a named sudo user, an SSH policy file, firewalld and automatic security patches. Then copy those steps into an Ansible playbook, keep it in version control and run it against every new server so they all match.
How do I make dnf-automatic install only security updates?
Install dnf-automatic, then in /etc/dnf/automatic.conf set upgrade_type = security and apply_updates = yes, and enable dnf-automatic.timer. Your Rocky Linux server then applies security fixes on its own, while you keep control of other package changes. The guide's sed command makes both edits in one line.
How do I check which ports are open on Rocky Linux?
Run sudo ss -tulpn to list every service listening on a TCP or UDP port, along with the process behind it. On Rocky Linux, compare that list with your firewalld rules and allow only the services you actually run, starting with ssh. Repeat the check from time to time, together with systemctl list-unit-files.
How do I harden SSH on Rocky Linux with MaxAuthTries?
Create /etc/ssh/sshd_config.d/10-hardening.conf with PermitRootLogin no, PasswordAuthentication no and MaxAuthTries 3, then run sshd -t and restart sshd. Keeping the policy in its own small file makes it easy to copy to other Rocky Linux servers. On version 8 that folder is not read, so set the lines in /etc/ssh/sshd_config instead.
Why keep all my Rocky Linux servers on one major version?
Keeping a group of Rocky Linux servers on the same major version means packages, repository names and defaults match, so your automation behaves the same on each. Mixing versions brings differences such as PowerTools on 8 instead of CRB. Record each server's release with cat /etc/rocky-release and its kernel with uname -r for later comparison.
Should I use the same sudo username on every Rocky Linux server?
Yes, the same named sudo user on every Rocky Linux server keeps your automation simple, since one playbook and one key setup work everywhere. Create it with useradd -m -G wheel, set a password and copy your key with ssh-copy-id from your own computer. Membership of the wheel group gives the user sudo rights.
Do I need to reboot after updating a new Rocky Linux server?
Yes, the guide reboots right after dnf upgrade -y so every Rocky Linux server starts from a fully patched state, with the new kernel running. Rebooting before you configure anything else means no restart is left pending later. Afterwards, confirm the running kernel with uname -r and note it for comparing servers.
Explore More VPS Hosting Options
Find the right server for your project.