−25%

on annual Windows plans, until 31 Oct. See plans

EQVPS
Get started

How to set up a Rocky Linux VPS: first steps after you get root

First ten minutes on a fresh Rocky Linux 9 VPS: update with dnf, add a sudo user with your SSH key, turn off root and password login, enable firewalld and automatic security updates. Every command tested on our image.

Rocky Linux 9 is the free RHEL-compatible choice: same packages, same dnf, same firewalld and SELinux. If you've set up Debian or Ubuntu, the order of steps is identical; the tools differ. This is the first ten minutes on a fresh Rocky 9 server.

Every command below was run on our Rocky Linux 9 image before publishing. On a clean server the whole sequence takes a couple of minutes.

1. Update the system

Log in as root with the password from your dashboard and update:

dnf -y upgrade

On our image it finished in seconds when we tested it, because the image was already current.

2. Create a sudo user and add your SSH key

On Rocky the admin group is wheel, not sudo:

useradd -m -G wheel deploy
passwd deploy                      # sudo will ask for this password

Put your public key on the server (how to create one). If you copied it to /root/key.pub:

install -d -m 700 -o deploy -g deploy /home/deploy/.ssh
install -m 600 -o deploy -g deploy /root/key.pub /home/deploy/.ssh/authorized_keys
restorecon -R /home/deploy/.ssh

restorecon sets the SELinux labels sshd expects. Without the right label, key login fails with no obvious error.

Open a second terminal and check that ssh deploy@YOUR.SERVER.IP works and sudo -v accepts the password. Keep the root session open until it does.

3. Turn off root and password login

This is where Rocky differs from a textbook sshd_config edit. Settings live in drop-in files under /etc/ssh/sshd_config.d/, and sshd uses the first value it finds. On our image the first file is 00-eqvps.conf, which allows root and password login so you can get in on day one. Change it there:

sed -i -e 's/^PermitRootLogin .*/PermitRootLogin no/' \
       -e 's/^PasswordAuthentication .*/PasswordAuthentication no/' \
       /etc/ssh/sshd_config.d/00-eqvps.conf
sshd -t && systemctl reload sshd
sshd -T | grep -E '^(permitrootlogin|passwordauthentication) '

The last command prints what sshd will actually enforce. You want:

permitrootlogin no
passwordauthentication no

After this, ssh root@… is refused even with a key, and deploy logs in with the key only.

4. Firewall: firewalld

The cloud image doesn't include firewalld. Install it, start it, and keep only what you need:

dnf -y install firewalld
systemctl enable --now firewalld
firewall-cmd --permanent --add-service=ssh
firewall-cmd --permanent --remove-service=cockpit
firewall-cmd --reload
firewall-cmd --list-services

The default zone opens cockpit (port 9090) and dhcpv6-client. Cockpit isn't installed, but there's no reason to leave its port open. When you add an app, open its port the same way, for example firewall-cmd --permanent --add-service=https.

5. Automatic security updates

dnf-automatic downloads updates on a timer. By default it doesn't install them, so switch that on:

dnf -y install dnf-automatic
sed -i 's/^apply_updates = .*/apply_updates = yes/' /etc/dnf/automatic.conf
systemctl enable --now dnf-automatic.timer
systemctl list-timers dnf-automatic.timer

If you'd rather get security fixes only, also set upgrade_type = security in the same file.

6. Leave SELinux on

getenforce prints Enforcing on a fresh server, and everything above works with it. When an app needs a non-standard port or directory, the fix is a label (semanage port, restorecon), not setenforce 0.

Which plan

Rocky 9 uses about 400 MB of RAM at idle. The Nano plan (1 GB, $3/mo) is enough for a single small service; Micro (2 GB, $5/mo) leaves room for a database. On NAT plans SSH comes in through a personal port shown in the dashboard. If you need ports 80/443 open to the world, take a plan with its own IPv4, such as Micro-IP at $10/mo.

Rocky Linux 9 is one of the images on the RHEL-family OS page and on every plan in VPS plans. Payment is in USDT, USDC or ETH on Base, Ethereum or Polygon. No ID or card is needed. If you'd rather drive the server from scripts, the API docs cover ordering, reinstalling and renewal.

FAQ

Is Rocky Linux the same as RHEL?

It is built from the same sources and aims to be bug-for-bug compatible with Red Hat Enterprise Linux 9, so RHEL guides, packages and habits (dnf, firewalld, SELinux) apply. You don't need a Red Hat subscription to use it.

Why does my SSH change not take effect on Rocky?

Rocky reads drop-in files from /etc/ssh/sshd_config.d/ in name order, and the first value it finds for a setting wins. On our image that first file is 00-eqvps.conf, so change the setting there and confirm the result with sshd -T before you close your session.

Should I turn SELinux off?

No. It is enforcing on a fresh install and the steps here work with it on. If you create files in unusual places for SSH or a web server, restorecon -R on that path fixes the labels. Turning SELinux off removes a real layer of protection to fix a labelling problem.

Can I change the SSH port?

On a plan with its own IPv4 you can, as long as you also allow the new port in firewalld and SELinux. On a NAT plan, leave sshd on 22: your personal external port is already forwarded to 22 inside the server, and moving sshd breaks that forward.

Which plan is enough for Rocky Linux?

Rocky 9 idles at about 400 MB of RAM, so the 1 GB Nano works for a small service. Micro with 2 GB is more comfortable once you add a database or containers.

Comments

No comments yet. Be the first.

Leave a comment

Comments are moderated before they appear.