Home Linux DistributionsArch Linux Monitor And Administer Linux Servers Using Cockpit Via Web Browser
Monitor And Administer Linux Servers Using Cockpit Via Web Browser

Monitor And Administer Linux Servers Using Cockpit Via Web Browser

By sk
4111 Views

Cockpit is a free, open source, server administration tool that allows you to easily monitor and administer Linux servers via a web browser. It helps the system admins to perform simple administration tasks, such as managing users, starting containers, administrating storage, configuring network, inspecting logs and so on. Switching between Terminal and Cockpit web interface is no big deal. You can the manage the system's services either from the Cockpit, or from the host's Terminal.

Cockpit also has an embedded terminal. Say for example, if you've started a service in Terminal, you can stop it from the Cockpit. Similarly, if an error occurs in the terminal, it can be seen in the Cockpit journal interface and vice versa. It is capable of monitoring multiple Linux servers at the same time. All you need to do is just add the systems that you wanted to monitor and Cockpit will look after them.

In this guide, we will see how to install and configure Cockpit on Linux (RPM and DEB based systems).

Install Cockpit In Linux

Cockpit is originally developed for RPM based systems such as RHEL, CentOS and Fedora. It has been now ported to other Linux distributions such as Arch Linux, Debian and Ubuntu.

Install Cockpit On Arch Linux

Cockpit is available in the official repositories of Arch Linux. To install Cockpit on Arch Linux and its derivatives like Manjaro Linux, run:

$ sudo pacman -S cockpit

Additionally, you should install "cockpit-machines" package, which enables managing virtual machines from the web browser.

$ sudo pacman -S cockpit-machines

After installing it, start and enable cockpit service using command:

$ sudo systemctl enable --now cockpit.socket

Install Cockpit On CentOS

Cockpit is available in the default repositories of CentOS 7. So, you can install it using command:

$ sudo yum install cockpit cockpit-machines

On CentOS 8:

$ sudo dnf install cockpit cockpit-machines

After installing it, start cockpit service using command:

$ sudo systemctl enable --now cockpit.socket

If you want to access the Cockpit web dashboard from other remote systems, you need to allow Cockpit service through firewall. To do so, run:

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

Install Cockpit On Fedora

Cockpit comes pre-installed in Fedora server. If it is not installed by any chance, install Cockpit on Fedora using command:

$ sudo dnf install cockpit cockpit-machines

After installing it, start cockpit service using command:

$ sudo systemctl enable --now cockpit.socket

If you want to access the Cockpit web dashboard, you need to allow Cockpit service through firewall. To do so, run:

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

Install Cockpit On RHEL

In Red Hat Enterprise Linux (RHEL) systems, make sure you have enabled [Extras] repository:

$ sudo subscription-manager repos --enable rhel-7-server-extras-rpms

Then, install Cockpit using command:

$ sudo yum install cockpit cockpit-machines

On RHEL 8:

$ sudo dnf install cockpit cockpit-machines

After installing it, start cockpit service using command:

$ sudo systemctl enable --now cockpit.socket

If you want to access the Cockpit web dashboard, you need to allow Cockpit service through firewall. To do so, run:

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

Install Cockpit On Debian

Cockpit is available in unstable and in backports for Debian 8 (Jessie) and Debian 9 (Stretch).

For Debian 9, enable the [backports] repository as root user like below:

# echo 'deb http://deb.debian.org/debian stretch-backports main' > /etc/apt/sources.list.d/backports.list

For Debian 8, enable the backports-sloppy repository:

# echo 'deb http://deb.debian.org/debian jessie-backports-sloppy main' > /etc/apt/sources.list.d/backports.list

Finally, install cockpit using command:

# apt-get update
# apt-get install cockpit cockpit-machines

Install Cockpit On Ubuntu

Cockpit is available in Ubuntu 17.04 and later, so you can install it using command:

$ sudo apt-get install cockpit cockpit-machines

Cockpit is available as an official backport for 16.04 LTS and later. Backports are enabled by default, but if you customized apt sources you might need to enable them manually.

After enabling backports, run the following command to install Cockpit on Ubuntu 16.04:

$ sudo apt-get install cockpit cockpit-machines

There is also an official PPA available for Cockpit for older Ubuntu versions. Add the PPA and install Cockpit as shown below.

$ sudo add-apt-repository ppa:cockpit-project/cockpit
$ sudo apt-get update
$ sudo apt-get install cockpit cockpit-machines

Monitor And Administer Linux Servers Using Cockpit Via Web Browser

Once installed, open your web browser and navigate to https://localhost:9090 (or) https://IP-address:9090. You will be pleased with Cockpit's login screen.

Cockpit Login Interface On Ubuntu 20.04 LTS Server:

Cockpit Login Interface On Ubuntu 20.04 LTS

Use any one of your system user's credentials to login.

Make sure you have checked the box that says - Reuse my password for privileged tasks to perform administrative tasks right from the Cockpit dashboard. If you don't select this option, you may need to enter the password each time when running administrative tasks.

Cockpit Login Interface On CentOS 8 Server:

Cockpit Login Interface On CentOS 8 Server

This is how my Cockpit's dashboard looks like in CentOS 8 server:

Cockpit dashboard in CentOS 8 server

As you see in the above screenshot, Cockpit's System information screen shows your server details, and graphs for CPU, Memory, Disk and network traffic. From this section, you can monitor your server's CPU usage, Memory and Swap usage, Disk usage and live network traffic. You can even update your server from here or restart it.

Here is how Cockpit dashboard looks like in Ubuntu 20.04 LTS:

Cockpit dashboard in Ubuntu 20.04 server

Logs section

Logs section displays the list of errors, warnings, and other important log details of your Linux server.

Logs section in Cockpit

Storage section

This section shows the no of available hard drives, filesystem details, storage logs and disk Read and Write usage.

Storage Section in Cockpit

Networking section

This section displays the list of available network interfaces and the IP address of each card. This is where we configure network settings such as creating Vlan, network bond and network bridge etc. In this section, we can also review the networking logs, incoming and outgoing traffic of the network interface card and the sending & receiving visual graphs.

Networking section in Cockpit

Accounts section

In this section, you can create new users, delete existing users, change user's password etc.

Accounts section in Cockpit

We can also disconnect any SSH sessions from here as well.

Services section

This section displays the list of active and inactive services.

Services section in Cockpit

Cockpit Terminal

Another notable feature of Cockpit web console is it has a built-in Terminal, which allows you to perform all sort of command line operations. You don't need to SSH to your server or don't need to install any remote communication tools. We can use the Cockpit Terminal to perform all command line operations as the way we do in the normal Terminal in the host.

Cockpit Terminal

How to add new hosts in Cockpit dashboard

Cockpit can be able to manage multiple servers at the same time.

Log in to the Cockpit web dashboard.

If you are on Ubuntu, make sure you've checked the option that says "Reuse my password for privileged tasks" under the password field. This allows you to run any administrative actions via Cockpit. If you don't check this option, you can't add any remote systems to your cockpit's dashboard or can't perform any administrative operations. In RHEL, CentOS systems, you can directly login as root user, so you don't have to check this option.

Login as admin user in Cockpit in Ubuntu

Click on the "Dashboard" button from the left pane to view the list of servers managed by Cockpit. You will see the all servers under "Servers" tab.

To add a new server, click on the + (plus) sign in the Servers tab.

View all linux systems managed by Cockpit

Enter the IP address of your remote server that you want to monitor and click Add.

Add new machine to Cockpit dashboard

You will see an unknown host key warning message. Just click Connect button to add the machine anyway.

Connect remote Linux machines to Cockpit

Enter your remote system's username and password.

Enter login details of remote system to add it to Cockpit

Congratulations! We have successfully added a new Linux remote system to the Cockpit dashboard. You will see the newly added systems under Servers tab in Dashboard.

New Linux host is added to Cockpit

Click on the remote system's name to start monitoring it from your Cockpit dashboard.

Monitor remote Linux system from Cockpit

Here, I am monitoring CentOS 8 server from Ubuntu 20.04 LTS server using Cockpit.

Similarly, you can add as many systems as you want to monitor and administer. Once you have gained the control over a remote system, you can completely administer it from your local system via cockpit. Further more, you can add, delete and manage users, add, remove, configure applications via Cockpit Terminal, reboot or shutdown the remote systems.


Recommended read:


Cockpit is opt for budding and seasoned Linux administrators. Cockpit installation and usage is fairly simple and straight forward. If you have a network full of remote systems, add all of them to cockpit dashboard and manage them like a pro.

Resources:

Thanks for stopping by!

Help us to help you:

Have a Good day!!

You May Also Like

10 comments

G May 9, 2019 - 2:52 pm

How many hosts we can monitor or add ?

Reply
sk May 9, 2019 - 4:52 pm

There is no limit. You can add as many systems as you want to monitor and administer.

Reply
Dave Matheis September 10, 2020 - 10:44 pm

Thanks for the article. I have been using Cockpit for a few years now, and it love it. One of the most useful features I have found is the SELinux module that lists access control errors.

One question I have had trouble finding an answer to, is when I rebuild a VM that I have had on the dashboard, I cannot add the new VM to the dashboard, because the key no longer matches. Do you know where these keys are stored so I can delete the old keys?

Thanks.

Reply
sk September 10, 2020 - 10:59 pm

Can you please post the error message or logs?

Reply
Dave Matheis September 11, 2020 - 3:05 am

I previously had a host on the dashboard with address 10.10.18.3, which I have since deleted. I also deleted it from the /etc/cockpit/machines.d/99-webui.json file. When I try to add a new entry to the dashboard with this same address I get the following error:

Incorrect Host Key
The key of 10.10.18.3 does not match the key previously in use. Unless this machine was recently replaced, it is likely that someone is trying to attack your connection to this machine.

I assume that the old key is stored on my cockpit host, but I have not been able to find and clear it so that I can add the new server with this same address.

Thanks for the help!

Reply
sk September 11, 2020 - 11:41 am

Looks like the VM’s SSH key problem. Try this:

ssh-keygen -R 10.10.18.3 -f /var/lib/cockpit/known_hosts

Make sure the IP address is correct.

Reply
Dave Matheis September 11, 2020 - 8:16 pm

Thanks for the assistance. The /var/lib/cockpit directory is empty, but I figured it out. The old key was in the /etc/ssh/ssh_known_hosts file. I removed the key from that file and then was able to add the new host at that same address to the dashboard.

Thanks again.

Reply
sk September 11, 2020 - 8:20 pm

Glad you sorted it out yourself. Regards.

Reply
Thierry September 24, 2020 - 2:33 am

Hello !
First of all thank you for this great article it helps me a lot.
I’m not an expert at linux but I’ve installed Ubuntu 20.04 LTS server and also Cockpit.
The only problem seems to be that cockpit has no rights to do anything.
For example, when I try to create a new pool, this error raise :
Failed to connect socket to ‘/var/run/libvirt/libvirt-sock’: Permission denied
all seems fine with the service :
sudo systemctl status libvirtd.socket
● libvirtd.socket – Libvirt local socket
Loaded: loaded (/lib/systemd/system/libvirtd.socket; enabled; vendor preset: enabled)
Active: active (running) since Wed 2020-09-23 20:31:37 UTC; 24min ago
Triggers: ● libvirtd.service
Listen: /run/libvirt/libvirt-sock (Stream)
Tasks: 0 (limit: 9299)
Memory: 60.0K
CGroup: /system.slice/libvirtd.socket
If I have a look at logs, many rights problems :
Failed to open file ‘/sys/kernel/security/apparmor/profiles’: Permission denied
Failed to read AppArmor profiles list ‘/sys/kernel/security/apparmor/profiles’: Permission denied

internal error: Unable to get DBus session bus connection: An AppArmor policy prevents this sender from sending this message to this recipient; type=”method_call”, sender=”(null)” (inactive) interface=”org.freedesktop.DBus” member=”Hello” error name=”(unset)” requested_reply=”0″ destination=”org.freedesktop.DBus” (bus)
Unable to open /dev/kvm: Permission denied
My user is in the sudoers groups
I googled a long time before posting so any help will be apreciated 🙂
Thanks in advance

Reply
sk September 24, 2020 - 11:39 am

Hi,

I already deleted the setup, so I couldn’t help to fix your issues. Here are two things I suggest you to do.

1. Please try installing Cockpit in a fresh Ubuntu 20.04 and see if it works.
3. Disable AppArmour as mentioned in this link -> https://askubuntu.com/questions/741035/disabling-apparmor-for-kvm

Reply

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More