How to Install Cockpit on Ubuntu 24.04 for Server Administration
Cockpit provides a browser-based control panel for managing server operations, including service tracking, app handling, networking, storage, log viewing, and user account administration. It offers an intuitive and modular interface, making it adaptable through various plugins for comprehensive server oversight.
This tutorial guides you through setting up Cockpit on Ubuntu 24.04, allowing you to manage and monitor server activities through a web-based dashboard.
Prerequisites
Before proceeding with the setup, ensure you have the following:
- An Ubuntu 24.04 server instance.
- A domain A record configured to point to your server’s IP, such as
cockpit.example.com
. - A dedicated non-root user with sudo privileges for Cockpit access, such as
cockpit_admin
.
Installing Cockpit on Ubuntu 24.04
Since Cockpit is part of Ubuntu’s standard repositories, you can follow these steps to update your system and install it.
Step 1: Refresh the package index
$ sudo apt update
Step 2: Install Cockpit
$ sudo apt install cockpit -y
Step 3: Set Cockpit to start on boot
$ sudo systemctl enable cockpit.socket
Step 4: Launch the Cockpit service
$ sudo systemctl start cockpit
Step 5: Confirm the Cockpit service is active
$ sudo systemctl status cockpit
Sample Output:
● cockpit.service - Cockpit Web Service Loaded: loaded (/usr/lib/systemd/system/cockpit.service; static) Active: active (running) since Tue 2024-12-10 18:50:56 UTC; 7s ago TriggeredBy: ● cockpit.socket Docs: man:cockpit-ws(8) Process: 12887 ExecStartPre=/usr/lib/cockpit/cockpit-certificate-ensure --for-cockpit-tls code=exited, > Main PID: 12900 (cockpit-tls) Tasks: 1 (limit: 1061) Memory: 2.7M (peak: 4.0M) CPU: 229ms CGroup: /system.slice/cockpit.service └─12900 /usr/lib/cockpit/cockpit-tls
With Cockpit successfully installed, it now listens for incoming connections on TCP port 9090.
If you’re operating on Debian 12, consider installing Cockpit as well to streamline server management through its browser-accessible, easy-to-navigate interface.
Enable SSL Encryption for Cockpit with Trusted Certificates
By default, Cockpit uses TCP port 9090 to accept incoming connections, but these are not encrypted. Accessing the web dashboard through unencrypted HTTP traffic may expose your server to various vulnerabilities. To secure the connection, you can enable HTTPS using verified SSL certificates from Let’s Encrypt. Below are the steps to configure SSL certificates for Cockpit using your domain name.
Step 1: Check if UFW Firewall is Active
$ sudo ufw status
Step 2: Allow Required Network Ports
Permit traffic to the Cockpit port:
$ sudo ufw allow 9090/tcp
Allow HTTP port for domain validation:
$ sudo ufw allow 80/tcp
Allow HTTPS connections for secure access:
$ sudo ufw allow 443/tcp
Reload UFW to activate the new rules:
$ sudo ufw reload
Step 3: Install Certbot with Snap
Install Snapd:
$ sudo apt install snapd -y
Use Snap to install Certbot:
$ sudo snap install certbot --classic
Step 4: Obtain a Let’s Encrypt Certificate
Request a new certificate using your domain and email. Replace the placeholders with your own data:
$ sudo certbot --standalone certonly -d cockpit.example.com -m cockpit@example.com --agree-tos
Run a test renewal to confirm automatic renewal is working:
$ sudo certbot renew --dry-run
Step 5: Configure Cockpit to Use the Certificate
Merge the certificate and private key into one file:
$ sudo cat /etc/letsencrypt/live/cockpit.example.com/fullchain.pem /etc/letsencrypt/live/cockpit.example.com/privkey.pem > cockpit.cert
Move the file to the appropriate Cockpit certificate directory:
$ sudo mv cockpit.cert /etc/cockpit/ws-certs.d/
Restart Cockpit to apply SSL changes:
$ sudo systemctl restart cockpit.socket
Access the Cockpit Web Interface
Use the following instructions to log in to the Cockpit web UI and begin managing your server:
Open a browser and go to:
https://cockpit.example.com:9090
Log in using your sudo-enabled user credentials. Cockpit doesn’t allow direct root logins via the interface, so make sure you authenticate with a non-root user account.
Once logged in, enable elevated privileges by clicking Turn on administrative access in the sidebar and entering your password again.
Administering the Server with Cockpit
Monitor System Health
In the Overview section, monitor system health, CPU and memory usage, active services, and performance metrics. Click View metrics and history for detailed usage statistics.
Manage Storage Devices
Select Storage from the menu to manage disk drives, view read/write performance, and diagnose storage-related issues.
Control System Services
Under Services, start, stop, or restart all system services including timers, sockets, paths, and targets.
Track Network Usage
Navigate to Networking to monitor active interfaces, view live bandwidth usage, and inspect logs for diagnosing network problems.
Inspect System Logs
Click Logs to filter entries by date, severity, and source daemon. Use filters and identifiers to isolate specific log events.
Manage Users and Groups
In the Accounts section, see all server users and groups. Click Create new account to add users with custom settings.
Open a Terminal
Use Terminal under the Tools section for direct shell access to your server environment.
Use Cockpit Podman to Manage Containers
Cockpit supports plugins like Cockpit Podman to manage containers visually. Follow these steps to set it up:
Step 1: Install the Podman Plugin
$ sudo apt update $ sudo apt install cockpit-podman -y
Step 2: Allow Traffic Routing to Containers
$ sudo ufw route allow proto tcp from any to any port 80 $ sudo ufw reload
Step 3: Deploy and Run a Container
In the Cockpit UI, click Podman containers, then Create container.
Provide a container name like app-example
and enter Nginx
as the image. Select docker.io/library/nginx
.
Under Integration, map port 80 for both host and container, leaving IP field blank.
Click Create and run to launch the container.
Once running, you’ll see its state listed as Running. Visit http://SERVER-IP
in your browser to confirm the Nginx default page is displayed.
Conclusion
In this tutorial, you installed Cockpit on Ubuntu 24.04 and used the Podman plugin to deploy containerized apps. Cockpit offers a flexible and powerful interface for managing server tasks. Additional features can be added by installing extensions such as Cockpit-Podman. Visit the official documentation for more customization options and details.