قالب وردپرس درنا توس
Home / Tips and Tricks / How to manage Linux servers with the Cockpit web interface

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̵

7;s self-contained, simple to set up and easy to use. We show you how to get started.

Managing multiple Linux servers

If you have to monitor multiple Linux computers or servers, you have a challenge. This is especially true if some of them run as headless systems without a monitor attached. For example, you have rack-mounted or remote servers in different buildings or a collection of Raspberry Pis scattered around your house.

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

If you are using Secure Shell (SSH) to connect to this, you can top or another terminal-based monitoring tool. You will get some useful information, but each tool has its own specific area of ​​interest. It’s a pain to have to move from tool to tool to view the various statistics of your remote Linux computer.

Unfortunately, there is no easy way to jump between the different tools that give you some of that information. And if you need to perform any remedial or administrative tasks, you must create a new connection to the remote computer or close the monitoring application. Then you need to use your existing SSH session to perform your management commands.

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

Cockpit gets its information from Application Programming Interfaces (APIs) that already exist within Linux. Because the information comes directly from the source, there is no custom collection or generation of the information, so it can be considered unadulterated.

Cockpit and User Accounts

Cockpit uses your Linux credentials, so you don’t need to configure users in it. To log in to Cockpit, simply use your username and current password. If you have accounts on different Linux computers that use the same username and password, Cockpit uses those credentials to connect to the remote machines.

Using the same password on different computers is of course a security risk and considered bad practice. However, if you only work with local computers that are not exposed to the Internet, you could conclude that the risk is small enough.

However, a much better solution is to set up SSH keys on each computer and then let Cockpit use them to connect to the remote computers.

RELATED: Create and install SSH keys from the Linux shell

Install 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

sudo apt-get install cockpit in a terminal window

On Fedora the command is:

sudo dnf install cockpit

sudo dnf cockpit install in a terminal window

On Manjaro you have to install Cockpit and a package called packagekit. This cross-platform 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 that they don’t have to write a version they are working with dnf, another for pacman, and so on.

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

sudo pacman -Sy cockpit

sudo dnf cockpit install in a terminal window

sudo pacman -Sy packagekit

sudo pacman packagekit in a terminal window

Launch cockpit

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

localhost:9090

You should then see the Cockpit login screen. If an error message appears stating that the site cannot be reached or the connection is refused, you may need to type the following commands to enable and start the Cockpit daemon:

sudo systemctl enable cockpit

sudo systemctl enable cockpit in a terminal window

sudo systemctl start cockpit

sudo systemctl starts cockpit in a terminal window

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

If you want to connect to other computers with the same credentials, select the check box next to “Reuse my password for remote connections.” If you use SSH keys to connect to remote computers or do not want to monitor other machines remotely at all, you can leave this box unchecked.

Cockpit login screen

The overview

The Cockpit webpage is fully responsive and will resize sensibly if you resize your browser window.

Cockpit sidebar in a browser window

The main screen contains 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 ‘Overview’.

Display of cockpit CPU usage in the main window

Cockpit also adapts when you use it on a phone.

Cockpit runs on an Android mobile

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

Failed service error notification in summary view in a browser window.

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

SSSD daemon error highlighted in Cockpit in a browser window

We click on ‘Start service’.

SSSD check page in Cockpit in a browser window

Now that the service is up and running, we can explore more of our monitored system.

SSD service normally runs in Cockpit in a browser window

You can click on “Overview” if it is visible in the sidebar; if not, click on the system icon and then click on ‘Overview’.

CPU and memory charts

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

Display of CPU and memory usage in Cockpit in a browser window

The following graphs are displayed:

  • “CPU usage”: The combined CPU usage for the total number of CPUs.
  • “Memory and exchange”: The RAM and the use of swap.
  • Disk I / O: Hard disk reads and writes.
  • “Network traffic”: All traffic in and out of the computer.

Overview graphs in Cockpit in a browser window

However, clicking on the name of each chart will reveal more detailed information:

  • If you click on “Disk I / O”, you will see the same information listed under “Storage” in the sidebar.
  • If you click on “Network Traffic”, you will see the same information listed under “Networks” in the sidebar.

Software updates

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

Available software updates in Cockpit in a browser window

To install them, just click on ‘Install all updates’.

Updates are performed in Cockpit in a browser window

Monitor multiple computers

Before trying to check another computer, complete the following steps:

  1. Install Cockpit on the other computer and then log in to Cockpit to check if it works. You do not need to run the browser interface on the remote computer when monitoring it remotely. However, doing so proves that Cockpit is properly installed and fully operational.
  2. Use SSH to remotely connect to the other computer from the computer you are monitoring it on. Confirm that you can use SSH on the remote computer, then log in with your current ID and password or with SSH keys.

Making sure these two steps work as expected makes monitoring a remote computer a breeze. Remember, if you connect 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.

The host drop-down list in Cockpit in a browser window

Click on ‘Add New Host’.

Add new hosts button in Cockpit in a browser window

Type the details of the remote computer (an IP address or host name). A color marker will appear at the top of the browser to help you identify which computer you are looking at.

Add a new host window in Cockpit in a browser window

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

New remote computer in the host list in Cockpit in a browser window

Click on the new remote computer to check it.

Monitoring the remote host in Cockpit in a browser window

The name of the host you are monitoring is displayed. The color marker at the top of the browser window is also the one you selected when you added that host.

Many more functions

There is much more you can do with Cockpit, including the following:

  • Get the general health status of a computer.
  • Track performance with CPU, memory, disk and network activities.
  • Change the host name.
  • Connect the host to a domain.
  • Open a terminal window.
  • Manage software updates, user accounts, services and daemons, partition tables, network connections and bridges, and IP addresses.
  • Create a RAID device.

More features are also coming. The developers have a working proof-of-concept version that displays a combined view of multiple hosts at once. Cockpit is not the most advanced management tool, but it is richly featured, easy to use, and meets most needs.




Source link