How to Install Cockpit on Ubuntu 20.04

Install Cockpit on Ubuntu Server 20.04

Cockpit is a web-based server administration tool for self-managed Linux servers. The free server control panel, backed by Red Hat, is unique in the sense that the graphical interface only shows settings for installed services. It is most beneficial to install Cockpit on Ubuntu if your server is primarily used for business networking:

  • File sharing
  • LDAP integration
  • Virtual machine (VM) hosting
  • RAID storage management

Cockpit simplifies tasks for advanced users already aware of which system apps are essential to their needs.

Install Cockpit on Ubuntu

  1. SSH into your Ubuntu server.
  2. Install Cockpit:
    apt install cockpit
  3. Install a free SSL certificate for your hostname with Certbot.
  4. Cockpit requires the SSL certificate and private key to be located in the “/etc/cockpit/ws-certs.d” directory as .crt and .key files respectively. You can combine the cert and private key into a new file or copy the Certbot files separately. We’ll do the latter. Remember to replace “example.com” with your Cockpit domain all four times:
    cp /etc/letsencrypt/live/example.com/fullchain.pem /etc/cockpit/ws-certs.d/example.com.crt && cp /etc/letsencrypt/live/example.com/privkey.pem /etc/cockpit/ws-certs.d/example.com.key
  5. Make the Cockpit user the owner of the new SSL files (replacing “example.com” within the command):
    chown cockpit-ws:cockpit-ws /etc/cockpit/ws-certs.d/example.com.crt /etc/cockpit/ws-certs.d/example.com.key
  6. Ensure that Cockpit will use the correct SSL (.crt) file in the “ws-certs.d” directory:
    remotectl certificate
    It should display the full path to the new cert file.
  7. Restart Cockpit to apply the SSL now:
    systemctl restart cockpit
  8. Now, create a script to ensure the Cockpit SSL files are updated automatically when Certbot renews your SSL:
    sudo nano /etc/letsencrypt/renewal-hooks/post/001-restart-cockpit.sh
  9. Add the following, replacing “example.com” with your Cockpit hostname, to automatically update the Cockpit SSL files and restart Cockpit afterwards:
    #!/usr/bin/env bash

    echo "SSL certificates renewed"

    cp /etc/letsencrypt/live/example.com/fullchain.pem /etc/cockpit/ws-certs.d/example.com.crt
    cp /etc/letsencrypt/live/example.com/privkey.pem /etc/cockpit/ws-certs.d/example.com.key
    chown cockpit-ws:cockpit-ws /etc/cockpit/ws-certs.d/example.com.crt /etc/cockpit/ws-certs.d/example.com.key

    echo "Cockpit Restarted"
    systemctl restart cockpit
  10. Save and exit the file.
  11. Make the script executable:
    chmod +x /etc/letsencrypt/renewal-hooks/post/001-restart-cockpit.sh
  12. Test the Certbot renewal process:
    sudo certbot renew --dry-run
    You should see “Cockpit Restarted” at the end.
  13. Ensure ports 9090 and 80 are enabled in your firewall.

Log into Cockpit

Visit your Cockpit instance in a web browser: example.com:9090.

The Cockpit Linux application integrates your system users for access. Login as an user with sudo privileges or create a sudo user to login. Check the box for “Reuse my password for privileged tasks” for sudo privileges in Cockpit.

Ubuntu Cockpit server login

The updates notification should be addressed immediately.

Linux Cockpit server overview

Select “Bug Fix Updates Available” to update the system. It should also clear any errors.

Available Cockpit software updates

Select “Install All Updates,” “Restart Now,” then “Reconnect.” Alternatively, you can restart the server from your Account Management Panel (AMP). Either option may take up to five minutes to complete.

Cockpit Overview

Below is a short summary of the Cockpit Overview dashboard.

Logs: view and sort system logs according to level of urgency and time frame.

Linux Cockpit server logs

Storage: visualize disk space and bandwidth, list filesystems, and check storage logs.

Cockpit disk I/O

Networking: manage bridges, VLANs, and other interfaces.

Cockpit network interfaces

Accounts: configure system user credentials, roles, password rules. You can also terminate user sessions and configure SSH keys.

Linux Cockpit server users

Services: manage system services and scheduled events (cron jobs).

Cockpit system services

Applications: list installed Cockpit applications. More are available at https://cockpit-project.org/applications.

Installed Cockpit applications

Terminal: use a command line interface (CLI) for advanced tasks.

Cockpit Terminal

Select “Dashboard” from the sidebar to view stats for CPU, memory, network, and disk I/O.

Cockpit I/O dashboard

You can change the Cockpit language by selecting your username and “Display Language” from the upper-right corner. System applications added after you install Cockpit on Ubuntu (e.g. Firewalld) will display respective configuration sections automatically.

What Next?

  1. If you haven’t already, install any necessary system services from the terminal. 
  2. Create any regular users needed.
  3. Check for Cockpit applications that may suit your needs at cockpit-project.org. We recommend the file manager application – Navigator.

Experience full control over your server environment and deploy the best operating and management systems that fit your needs with our reliable Cloud VPS Hosting!

InMotion Hosting Contributor
InMotion Hosting Contributor Content Writer

InMotion Hosting contributors are highly knowledgeable individuals who create relevant content on new trends and troubleshooting techniques to help you achieve your online goals!

More Articles by InMotion Hosting

Was this article helpful? Join the conversation!