Install SSL Certificates on Cockpit

Install SSL Certificates on Cockpit

Are you looking to secure your Cockpit server and protect sensitive data? Follow these steps to Install SSL Certificates on Cockpit and protect your server infrastructure.

Table of Contents


Cockpit is a popular open-source web-based interface for managing Linux systems. It is designed to make Linux system administration tasks easy and user-friendly. Cockpit was first introduced in 2013 and has since become an indispensable tool for Linux professionals. One of the features that make Cockpit stand out is its ability to support SSL/TLS encryption for secure connections. In this article, we will provide a step-by-step guide on how to install SSL certificates in Cockpit.

Prerequisites or System Requirements

Before we begin, you need to ensure that you have the following:

  1. A Linux server with Cockpit installed.
  2. A domain name for the server (optional).
  3. A self-signed or a non self-signed SSL certificate.

Cockpit and its popular features

Cockpit is a web-based interface that allows you to manage your Linux server through a web browser. It offers a simple and intuitive user interface that makes it easy to manage your server, monitor its performance, and troubleshoot issues. In this article, we will focus primarily on the RHEL or CentOS operating system.

Some of its most popular features include:

  1. Real-time monitoring of system resources like CPU, RAM, and disk usage.
  2. Management of system services, including starting, stopping, and restarting services.
  3. Management of users and groups.
  4. Viewing system logs for troubleshooting purposes.
  5. Network configuration and management.

Step-by-Step Procedure for Installing a Self-Signed Certificate

Follow these steps carefully to install a self-signed SSL certificate on your Cockpit Server.

Step 1: SSH to your Cockpit Server

Log in (SSH) to your Linux server and open a terminal window.

Step 2: Generate Self-Signed Certificate

A self-signed SSL certificate is useful for testing or development purposes. To generate a self-signed certificate, use the following command:

					$ sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/cockpit/ws-certs.d/cockpit-selfsigned.key -out /etc/cockpit/ws-certs.d/cockpit-selfsigned.cert

This command generates a self-signed certificate that is valid for 365 days and saves it in the specified directory.

Step 3: Install Self-signed Certs

To install the self-signed SSL certificate, run the following command (s):

					$ sudo mkdir -p /etc/systemd/system/cockpit.service.d/
$ sudo vim /etc/systemd/system/cockpit.service.d/override.conf

Add the following lines to the file:


Save and close the file.

Step 4: Restart the Cockpit Service

Restart the Cockpit service by typing the following command:

					$ sudo systemctl daemon-reload
$ sudo systemctl restart cockpit

Step-by-Step Procedure for Installing a Non Self-Signed Certificate

Step 1: Obtain Self-signed Cert

For production use, it is recommended to use a non self-signed SSL certificate from a trusted Certificate Authority (CA). Here is how to generate a non self-signed SSL certificate:

  • Purchase an SSL certificate from a trusted CA such as DigiCertGlobalSign, or Verisign.

  • Download the certificate (provided by the CA). The private key should reside on your Cockpit server (see Generate CSR and Keys section).

Step 2: Copy Certificate and Key files

Copy the certificate and key files to the following directory /etc/cockpit/ws-certs.d/:

					$ sudo mkdir /etc/cockpit/ws-certs.d/
$ sudo cp /path/to/<your_cockpit_hostname>.crt /etc/cockpit/ws-certs.d/
$ sudo cp /path/to/<your_cockpit_hostname>.key /etc/cockpit/ws-certs.d/

Replace <your_cockpit_hostname> with the actual hostname of your cockpit server. In this instance, our hostname is:

Generate CSR and keys

CAs generally require a Certificate Signing Request (CSR) from which they can generate and provide you with a SSL certificate. Here’s how we can generate a CSR file in two steps and avoid having to answer the usual prompts.

1. Log onto your cockpit server

2. Using your favorite text editor, open a file and call it what you want. For the purpose of this exercise we’re calling it csr_form.txt

3. Copy and paste the following entries (below) to that file and replace it with your information.

default_bits = 2048
prompt = no
default_md = sha256
req_extensions = req_ext
distinguished_name = dn

[ dn ]
L=San Diego
CN =

[ req_ext ]
subjectAltName = @alt_names

[ alt_names ]
DNS.1 =
IP.1 =

Run the following command to generate a CSR and key file (this is for illustrative purposes, your csr_form.txt will vary depending on your environment):

					$ openssl req -new -sha256 -nodes -out $HOSTNAME.csr -newkey rsa:2048 -keyout $HOSTNAME.key -config <( cat csr_form.txt )
Install SSL Certificates on Cockpit

Photo by admingeek from Infotechys

That’s it. You’ve successfully generated a CSR and key file.

How to check the CSR file

Run this command to check the contents of your .csr file.

					$ openssl req -in -noout -text

The output (below) shows the contents of the file.

					$ openssl req -in -noout -text
Certificate Request:
        Version: 1 (0x0)
        Subject: C = US, ST = California, L = San Diego, O = DEV, OU = INFOTECHYS, emailAddress =, CN =
        Subject Public Key Info:
            Public Key Algorithm: rsaEncryption
                Public-Key: (2048 bit)
                Exponent: 65537 (0x10001)
            Requested Extensions:
                X509v3 Subject Alternative Name: 
          , IP Address:
    Signature Algorithm: sha256WithRSAEncryption
    Signature Value:


Step 3: Combine Certificate and Key files

As the root user, navigate to the /etc/cockpit/ws-certs.d directory:

					# cd /etc/cockpit/ws-certs.d/

Combine both the .crt and .key files into one 0-<your_cockpit_hostname>.cert file. We’ll use our hostname ( as an example (below):

					$ cat >>
$ cat >>

Now, change the 0-<your_cockpit_hostname>.cert file ownership to cockpit-ws.

					$ chown :cockpit-ws /etc/cockpit/ws-certs.d/

Step 4: Set Permissions

Set the correct permissions on the files by typing the following command:

					$ chmod 640 /etc/cockpit/ws-certs.d/
$ chmod 600 /etc/cockpit/ws-certs.d/
$ chmod 600 /etc/cockpit/ws-certs.d/

Again, replace ( with the actual hostname of your cockpit server.

Step 5: Restart Cockpit Service

Restart the Cockpit service by typing the following command

					$ systemctl restart cockpit

Open a web browser and navigate to the Cockpit web interface by typing the IP address or domain name of your server (along with the cockpit port 9090) in the address bar (https://<your_cockpit_hostname>:9090). The Cockpit interface should now be accessible over an SSL/TLS encrypted connection.

Install SSL Certificates on Cockpit

Photo by admingeek from Infotechys

Best Practices

Here are some best practices to follow when installing SSL certificates in Cockpit:

  • Always use SSL/TLS encryption for secure connections.
  • Use non self-signed SSL certificates from trusted Certificate Authorities.
  • Keep your SSL certificates up-to-date by renewing them before they expire.
  • Use strong encryption algorithms like AES256-SHA256 for your SSL certificates.
  • Always backup your SSL certificate and private key files.


Securing a Cockpit server with SSL certificates is essential for protecting sensitive data and preventing unauthorized access. In this article, we provided step-by-step procedures for installing both self-signed and non self-signed SSL certificates.

We also discussed some best practices for ensuring maximum server security. By following these guidelines, Linux professionals can confidently manage their servers with Cockpit and ensure the security of their system.

Was this article helpful to you? If so, leave us a comment below and share!

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *