How to Install Cockpit on AlmaLinux 9, Rocky Linux 9 and CentOS Stream 9
Install and secure the Cockpit web console on AlmaLinux 9, Rocky Linux 9 or CentOS Stream 9, the supported replacements for CentOS 7.
Cockpit is a web console for Linux servers: from a browser you can read logs, manage services, storage, networking, user accounts and software updates, and open a terminal. This guide installs it on AlmaLinux 9, Rocky Linux 9 or CentOS Stream 9, opens the firewall for it and shows how to log in without exposing the root account. CentOS 7 reached end of life on 30 June 2024 and no longer receives updates, so a new server should run one of these RHEL 9 compatible releases instead; the steps are the same on all three.
Requirements
- A server running AlmaLinux 9, Rocky Linux 9 or CentOS Stream 9.
- A regular user with
sudorights (a member of thewheelgroup). The examples usedeploy. - TCP port 9090 reachable from your computer, or SSH access if you prefer a tunnel.
Step 1: Install Cockpit
Cockpit is in the standard repositories, so no extra repository such as EPEL is needed. Update the system first, then install the package:
sudo dnf upgrade -y
sudo dnf install -y cockpit
Many server images already include it; in that case dnf reports that there is nothing to do.
Step 2: Enable the Cockpit socket
Cockpit does not run permanently. systemd listens on port 9090 and starts the web service only when a browser connects, so you enable the socket rather than the service:
sudo systemctl enable --now cockpit.socket
Step 3: Open the firewall
firewalld ships a predefined cockpit service. Add it to the public zone and reload:
sudo firewall-cmd --permanent --zone=public --add-service=cockpit
sudo firewall-cmd --reload
If your provider has its own firewall in front of the server, allow TCP 9090 there as well. To limit access to one address instead of the whole internet, skip the commands above and add a rich rule:
sudo firewall-cmd --permanent --zone=public --add-rich-rule='rule family="ipv4" source address="198.51.100.25" port port="9090" protocol="tcp" accept'
sudo firewall-cmd --reload
Step 4: Log in
Open the console in a browser, replacing the address with your server's IP:
https://203.0.113.10:9090
Cockpit generates a self-signed certificate on first use, so the browser shows a warning until you install a trusted certificate. Accept it for now and sign in with your regular user and password.
Direct root logins are disabled by default on these releases: the name root is listed in /etc/cockpit/disallowed-users. Log in as your sudo user and click Turn on administrative access (shown as Limited access in the top bar) and enter your password again. Cockpit then uses sudo for privileged actions.
Step 5: Verify the installation
Check that the socket is listening:
systemctl status cockpit.socket
sudo ss -tlnp | grep 9090
The socket should be active (listening). cockpit.service itself is only active while someone is logged in.
Step 6: Add optional pages
The base package covers the overview, logs, services, networking, accounts and terminal. Further pages are separate packages:
| Package | Adds |
|---|---|
cockpit-storaged | Disks, partitions, LVM, RAID and NFS mounts |
cockpit-packagekit | Software updates |
cockpit-podman | Podman containers and images |
cockpit-machines | libvirt virtual machines |
sudo dnf install -y cockpit-storaged cockpit-packagekit cockpit-podman
Reload the browser page and the new entries appear in the menu. Container management is built around Podman, the container engine of the RHEL family; there is no Docker page.
Use a trusted certificate
Cockpit reads its certificate from /etc/cockpit/ws-certs.d/. Place a certificate file ending in .crt (the full chain) and its private key with the same base name ending in .key in that directory, for example 50-example.crt and 50-example.key, then restart the service:
sudo systemctl restart cockpit
When several certificates are present, the one whose file name sorts last is used.
Keep Cockpit off the public internet
If you only need the console occasionally, do not open port 9090 at all. Forward it through SSH from your computer:
ssh -L 9090:localhost:9090 deploy@203.0.113.10
While that session is open, browse to https://localhost:9090. Cockpit is updated together with the rest of the system by sudo dnf upgrade.
Frequently asked questions
Why does systemctl status cockpit show the service as inactive?
That is expected. Cockpit is socket-activated: only cockpit.socket stays active, and the web service starts on the first connection and stops again when idle. An idle server spends no memory on it.
Can I log in as root?
Only if you remove root from /etc/cockpit/disallowed-users. Leaving it there is safer: password guessing against a known account name is the most common attack on an exposed login page, and a sudo user with administrative access can do the same work.
Does Cockpit also run on Debian and Ubuntu?
Yes. The package is called cockpit there too, and the Cockpit project recommends installing it from the release's backports repository to get a current version. See the Cockpit installation page for each distribution.