Table of Contents

Installing Cockpit on CentOS 7

Cockpit is already included in CentOS 7.x official base repository, so we can install directly from ‘yum‘ command.

Installation Steps:

1. Open your terminal app in CentOS 2. Download and install cockpit using yum command. 3. Enable the cockpit. 4. Open the firewall for cockpit and reloading the firewall. 5. Logging In Cockpit Admin Panel.

Step-wise implementation of installations:

Step 1: Open your Terminal

You can launch the terminal app using ‘ctrl+shift+T’ or from application menu.

Step 2: Download and install Cockpit

Use the command below to download and install the cockpit.

   sudo yum install cockpit
   

We will need admin rights in order to install new applications in our system, that’s why we are using sudo command. You may need to enter your root password because of security reasons.

It may ask you to confirm again whether you are sure to install cockpit. In that case, you just need to type ‘y’ and press enter for the confirmation.

Once the package is installed successfully without any errors, your screen will show a ‘Complete’ message, just like in the picture below. At this stage, you are ready to proceed with the next steps.

Step 3: Enable the Cockpit

Use the command below to enable the cockpit in our system.

   sudo systemctl enable --now cockpit.socket
   

Step 4: Open the firewall for Cockpit

Use the command below to open the firewall for cockpit.

   sudo firewall-cmd --permanent --zone=public --add-service=cockpit

We will need to reload the firewall in order to reflect the changes. This can be easily done by using the command below.

   sudo firewall-cmd --reload
   

Step 5: Loading the Cockpit Web Interface

Now we are ready to use Cockpit. Open any browser of your preference and type the URL as: https://SERVER_IP:9090. Where server IP should be replaced with the actual IP of your server. You can also use https://localhost:9090 to login into Cockpit.

Use your admin username and root password which you use for CentOS to login into the admin panel. After the successful login, you will see the admin Console of Cockpit web interface

In this way, you can easily install and use cockpit in CentOS 7.x or any other later version.

Use Let’s Encrypt certificates with Cockpit

By using the aapanel we can generate the SSL for the Cockpit url Cockpit panel

After generated the SSL certificate (fullchain.pem,privkey.pem) it has been available in below locations.

    /www/server/panel/vhost/letsencrypt/sitename 
    

Configure Cockpit

Regarding SSL certificates, Cockpit has requirements that are not satisfied by default.

In particular, the certificate needs the certificate and the private key to be in the same file, which is not the case when using Certbot. And the certificate and key file must be saved in .cert format and be put in the /etc/cockpit/ws-certs.d dir.

To solve this, we will create a combined certificate and key file and then save it in the .cert format.

    "cat /www/server/panel/vhost/letsencrypt/sitename/fullchain.pem /www/server/panel/vhost/letsencrypt/sitename/privkey.pem >/etc/cockpit/ws-certs.d/sitename.cert"

Where:

  1. cat is the standard Unix utility to concatenate files, or print them on standard output.
  2. Itemfullchain.pem and privkey.pem are your site’s public certificate and private key, respectively. These will be different depending on what you generated for Certbot.
  3. /etc/cockpit/ws-certs.d is the directory where you want to save your certificate and key file.

Once you have created the certificate and key file, restart the cockpit service to load the new SSL certificate.

   sudo systemctl restart cockpit.socket
   

Now you can access your website with https instead of http. Navigate to Panel, click on the padlock in the address bar, and see a Connection is a secure message. Means, the certificate is successfully installed.


Update the SSL Certificates using the aaPanel

1. Renewal the site using the aaPanel as per the below screen shot.


2. Copy the Certificate (CRT/PEM) and Private key (KEY) and past in same Notepad.
3. Goto Cockpit certificate location /etc/cockpit/ws-certs.d and edit the panel.itcybertek.in.cert and copy
the content from the notepad and past in the file panel.itcybertek.in.cert.
4. And restart the cockpit service sudo systemctl restart cockpit.socket

Install SSL Certificates on Ubuntu Using aapanel

1. Follow the same step1 as mention above.
2. Copy the Certificate (CRT/PEM) and Private key (KEY) and past in same Notepad
3. Goto Cockpit certificate location /etc/cockpit/ws-certs.d and edit the vpc.itcybertek.in.cert past the Certificate (CRT/PEM) and edit the vpc.itcybertek.in.key past the Private key (KEY).
4. Restart the Cockpit Service Restart the Cockpit service by typing the following command:

$ sudo systemctl daemon-reload
$ sudo systemctl restart cockpit

Systemd Issues:

Problems with systemd units related to Cockpit, such as a failed state or incorrect configuration.

Resolution: Try restarting and enabling the Cockpit socket and service:

      sudo systemctl stop cockpit.socket cockpit
      sudo systemctl reset-failed cockpit.socket cockpit
      sudo systemctl start cockpit
      sudo systemctl enable --now cockpit.socket