Manage your Raspberry Pi with Cockpit

Establish central control over your Raspberry Pis with Cockpit.
110 readers like this.
Kurt Stam's LEGO-encased Raspberry Pi cluster

Photo by Kurt Stam CC BY-SA 4.0

Last year, I wrote about using Cockpit to manage my Linux servers. It is a web-based tool that gives you a clean, powerful interface for managing multiple servers and their associated services and applications. It also eases regular day-to-day administrative tasks.

In this article, I'll describe how to install the Cockpit web console for Linux servers on the Raspberry Pi operating system (OS), the standard OS provided by the Raspberry Pi Foundation. I'll also provide brief descriptions of its features.

Installing Cockpit on Raspberry Pi OS

Log into your Raspberry Pi system using secure shell (SSH) using an account with sudo privileges. Set up an account if you haven't already done so:

$ ssh pibox
alan@pibox's password:
Linux pibox.someplace.org 5.10.17-v7+ #1403 SMP Mon Feb 22 11:29:51 GMT 2021 armv7l

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Tue May  4 09:55:57 2021 from 172.1.4.5
alan@pibox:~ $

The command to install the Cockpit web console is as simple on Raspberry Pi OS as it is on Linux servers:

$ sudo apt install cockpit

Cockpit only requires 60.4 kB of disk space. Together with its several package dependencies, total usage is 115MB.

The installation process will take care of setting up and starting the services. You can verify the status by using the systemctl command:

$ systemctl status cockpit.socket
● cockpit.socket - Cockpit Web Service Socket
   Loaded: loaded (/lib/systemd/system/cockpit.socket; enabled; vendor preset: enabled)
   Active: active (listening) since Tue 2021-05-04 10:24:43 EDT; 35s ago
     Docs: man:cockpit-ws(8)
   Listen: 0.0.0.0:9090 (Stream)
  Process: 6563 ExecStartPost=/usr/share/cockpit/motd/update-motd  localhost (code=exited, status=0/SUCCESS)
  Process: 6570 ExecStartPost=/bin/ln -snf active.motd /run/cockpit/motd (code=exited, status=0/SUCCESS)
    Tasks: 0 (limit: 2181)
   CGroup: /system.slice/cockpit.socket

Using Cockpit

Connecting

The default listening port is 9090. Open your favorite web browser and enter the address, e.g., https://pibox:9090.

You can now log in with your regular user account. Again, it is helpful to have sudo privileges on this account—most likely the same one you use to SSH and run Apt. Be sure to check the box for "Reuse my password for privileged tasks".

Managing your Pi

Cockpit's initial screen starts with System and will provide details and graphs of current CPU and memory usage.

You can view hardware details from this screen.

Explore the column on the left by clicking each item (e.g., Logs, Storage, Services, etc.). These are the standard Cockpit sections and are fairly self explanatory. Let me quickly describe each.

Logs

This section shows the logs. They can be filtered by date and severity.

Storage

The storage section shows the physical drives and RAID devices that are installed. Details such as size and serial number are shown. Graphs for read/write activity and actual space usage are displayed. Storage specific logs are presented at the bottom.

Networking

This section displays send and recieve activity, IP addresses, and network specific logs. You can also add more networking devices; such as bonds, bridges, and VLANs using the respective buttons.

Accounts

Existing accounts are shown here. Click each to manage or use the Create New Account button to add users. Accounts can be deleted here also.

Services

This section allows the administrator to view the status of all of the system services. Clicking any service takes you to a screen with the standard tasks of start, restart, and disable.

Applications

Normally, this screen provides various applications for managing functions such as the 389 Directory Server or creation of Podman containers. On my Raspberry OS though, this screen only displayed the message, "No applications installed or available". At the time of writing, perhaps this has not yet been implemented. Although, you do have to wonder whether these types of processes would be too heavy for the Raspberry PI hardware.

Software Updates

Keeping software up to date is one of the most important tasks for any system administrator. Cockpit's Software Updates section checks and applies updates.

Terminal

One of Cockpit's neatest features is the terminal. You can use it instead of opening a separate terminal emulator and using SSH. I used the terminal to install ScreenFetch:

$ sudo apt install screenfetch

And I used ScreenFetch to produce this screenshot:

Centralized control with Cockpit

Cockpit behaves on Raspberry Pi just like it does on any other Linux system. You can add it to a dashboard for centralized control. It allows organizations to integrate Raspberry Pi-based services and systems into their overall Linux infrastructure anywhere Cockpit is used as a management dashboard solution. This is highly convenient, given that Pis are often run headless in high-density racked data centers that generally lack KVM access.

What to read next
Alan Formy-Duval Opensource.com Correspondent
Alan has 20 years of IT experience, mostly in the Government and Financial sectors. He started as a Value Added Reseller before moving into Systems Engineering. Alan's background is in high-availability clustered apps. He wrote the 'Users and Groups' and 'Apache and the Web Stack' chapters in the Oracle Press/McGraw Hill 'Oracle Solaris 11 System Administration' book.

8 Comments

Good article...

How would one remotely manage Cockpit on devices at home ( i.e., behind firewall, private IPs only) ?

I installed cockpit remotely accessing raspberry over wifi. The default randomised MAC feature of the network-manager has broken my session and bypassed my DHCP reservations. It took me a while to find my way back to my raspberry and figure out what is going on.

as @jordana mentioned, this randomises your MAC. If you have DHCP reservations or e.g. various MAC rules on the router, this will bypass them. If you're installing Cockpit for the first time and through SSH, you're gonna have a bad time. My SSH session went down during install, so I couldn't see what was really going on. And that sucks, the install should have at least warned the user that such thing will happen.
And even if you apt purge Cockpit*, your MAC will still be randomised on every system reboot. It took me a while to figure out how to fix this. But even so, I rather restored a backup via Timeshift afterwards.

I removed network-manager that made DHCP fallback on factory MAC. But I agree with you that changing MAC and IP address during installation is far too intrusive, and there should be an option to avoid that.

In reply to by misokatsu_soda_pan

@jordana, i just re-imaged raspian OS after installing cockpit because of mac address randomization. can you please provide instructions?

Also, my 'Recommended Software' stopped working, throws the below error 'Error updating package data - Cannot refresh cache whilst offline'. Not sure what else is broke?

@kkumar_k
I used
sudo apt remove network-manager
I have seen some side effects of MAC randomisation on my Wi-Fi access point, blocking my raspberry. Since I removed network-manager and rebooted my raspberry, it is working good again.

In reply to by kkumar_k

I found the network side failing to connect, yet I was connected. I went with webmin in the end.

Creative Commons LicenseThis work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License.