How to Manage Linux Servers with the Cockpit Web Interface


A terminal window on a Linux computer system.
Fatmawati Achmad Zaenuri/Shutterstock

You can easily monitor and manage multiple Linux computers with Cockpit, a browser-based administration and dashboard tool. It’s self-contained, simple to set up, and easy to use. We’ll show you how to get started.

Managing Multiple Linux Servers

If you have multiple Linux computers or servers to monitor, you have a challenge. This is especially true if some of them are running as headless systems with no monitor attached. For example, you might have rack-mounted or remote servers located in different buildings or a collection of Raspberry Pi’s scattered around your home.

How can you monitor the health and performance of all of these?

If you use Secure Shell (SSH) to connect to them, you can run top or another terminal-based monitoring tool. You’ll get some useful information, but each tool has its own specific area of interest. It’s awkward to have to move from tool to tool to view the different metrics of your remote Linux computer.

Unfortunately, there’s no convenient way to hop between the different tools that give you some of that information. Plus, if you have to perform any remedial or administrative tasks, you have to make a fresh connection to the remote computer or close the monitoring application. Then, you have to use your existing SSH session to execute your administration commands.

Cockpit ties many common monitoring and administration requirements into a browser-based console, making it easier to monitor and maintain multiple Linux computers.

Cockpit obtains its information from application programming interfaces (APIs) that already exist within Linux. Because the information comes straight from the source, there’s no custom collection or generation of the information, so it can be considered unadulterated.

Cockpit and User Accounts

Cockpit uses your Linux login credentials, so there’s no need to configure users within it. To log in to Cockpit, you just use your username and current password. If you have accounts on different Linux computers that use the same username and password, Cockpit will use those credentials to connect to the remote machines.

Of course, using the same password on different computers is a security risk and is considered a bad practice. However, if you’re working solely with local computers that aren’t exposed to the internet, you might conclude the risk is small enough.

A far superior solution, though, is to set up SSH keys on each computer, and then allow Cockpit to use those to connect to the remote computers.

RELATED: How to Create and Install SSH Keys From the Linux Shell

Installing Cockpit

Cockpit is in the core repositories for the major Linux families. To install Cockpit on Ubuntu, type the following:

sudo apt-get install cockpit

On Fedora, the command is:

sudo dnf install cockpit

On Manjaro, you have to install Cockpit and a package called packagekit. This platform-independent package sits on top of the native package management system of a Linux distribution. It provides a consistent API for application software.

Developers can write software that works with packagekit, and their software can then talk to the package manager of any Linux distribution. This means they don’t have to write a version that will work with dnf, another for pacman, and so on.

Fortunately, packagekit is already installed on Ubuntu and Fedora, so you just type the following two commands:

sudo pacman -Sy cockpit

sudo pacman -Sy packagekit

Launching Cockpit

To start using Cockpit, open your browser, type the following in the address bar, and then press Enter:

localhost:9090

You should then see the Cockpit login screen. If an error appears telling you the site can’t be reached or the connection was refused, you might have to type the following commands to enable and start the Cockpit daemon:

sudo systemctl enable cockpit

sudo systemctl start cockpit

When Cockpit launches, the login screen appears; just log in with your existing Linux credentials.

To connect to other computers using these same credentials, select the checkbox next to “Reuse My Password for Remote Connections.” If you’re using SSH keys to connect to remote computers or won’t be remotely monitoring other machines at all, you can leave this box unchecked.

The Overview

The Cockpit web page is completely responsive and will adjust sensibly if you change the size of your browser window.

The main display features a list of task categories in a sidebar on the left, while the rest of the window contains information related to the selected category. The default view is the “Overview.”

Cockpit also adapts when you use it on a phone.

On our test computer, we see that an error has been flagged because a service has failed.

We click the “1 service has failed” link to move to the System Services view. The System Security Services Daemon (SSSD) has failed to start, so we click the “sssd” link to move to the SSSD control page.

We click “Start Service.”

With the service now running, we can explore more of our monitored system.

You can click “Overview” if it’s visible in the sidebar; if not, just click the System icon, and then click “Overview.”

CPU and Memory Graphs

In the CPU and Memory usage pane, click “View Graphs.”

The following graphs are displayed:

  • “CPU Usage”: The combined CPU usage for the total number of CPUs.
  • “Memory & Swap”: The RAM memory and swap usage.
  • “Disk I/O”: Hard drive reads and writes.
  • “Network Traffic”: All traffic in and out of the computer.

If you click the name of each graph, you can see more detailed information, however:

  • If you click “Disk I/O,” you see the same info that’s under “Storage” in the sidebar.
  • If you click “Network Traffic,” you see the same info that’s under “Networking” in the sidebar.

Software Updates

You can click “Software Updates” in the sidebar to see a list of available updates.

To install them, just click “Install All Updates.”

Monitoring Multiple Computers

Before you try to monitor another computer perform the following steps:

  1. Install Cockpit on the other computer, and then log in to Cockpit to verify it’s working. You don’t have to have the browser interface running on the remote machine when you’re remotely monitoring it. However, if you do, it will prove Cockpit has been installed correctly and is fully operational.
  2. Use SSH to remotely connect to the other computer from the one on which you’re monitoring it. Confirm you can use SSH on the remote computer, and then log in, using either your current ID and password or SSH keys.

Ensuring these two steps work as expected makes monitoring a remote computer a breeze. Remember, if you’re connecting to remote hosts with the same username and password as your monitoring computer, you must select the “Reuse My Password for Remote Connections” box.

On the monitoring computer, click the drop-down arrow next to the host.

Click “Add New Host.”

Type the details of the remote computer (either an IP address or hostname). A color highlight appears at the top of the browser to help you identify which computer you’re looking at.

Click “Add” when you’re ready. You should now see the remote computer in the list of available hosts; click the drop-down arrow next to it.

Click the new remote computer to monitor it.

The name of the host you’re monitoring will be displayed. The color highlight at the top of the browser window will also be the one you selected when you added that host.

Many More Features

There’s a lot more you can with Cockpit, including the following:

  • Get the overall health status of a computer.
  • Monitor performance with CPU, memory, disk, and networking activity.
  • Change the hostname.
  • Connect the host to a domain.
  • Open a terminal window.
  • Manage software updates, user accounts, services and daemons, partition tables, network bonds and bridges, and IP addresses.
  • Create a RAID device.

More features are on their way, as well. The developers have a working proof-of-concept version that displays a combined view of multiple hosts at once. Cockpit isn’t the most sophisticated management tool, but it’s richly featured, simple to use, and will satisfy most needs.

Exit mobile version