Sick Gaming
Fedora - Using Cockpit to graphically manage systems, without installing Cockpit on - Printable Version

+- Sick Gaming (https://www.sickgaming.net)
+-- Forum: Computers (https://www.sickgaming.net/forum-86.html)
+--- Forum: Linux, FreeBSD, and Unix types (https://www.sickgaming.net/forum-88.html)
+--- Thread: Fedora - Using Cockpit to graphically manage systems, without installing Cockpit on (/thread-101587.html)



Fedora - Using Cockpit to graphically manage systems, without installing Cockpit on - xSicKxBot - 09-26-2023

Fedora - Using Cockpit to graphically manage systems, without installing Cockpit on

<div style="margin: 5px 5% 10px 5%;"><img src="https://www.sickgaming.net/blog/wp-content/uploads/2023/08/using-cockpit-to-graphically-manage-systems-without-installing-cockpit-on-them.png" width="1024" height="748" title="" alt="" /></div><div><p>It probably sounds too good to be true: the ability to manage remote systems using an easy to use, intuitive graphical interface – without the need to install extra software on the remote systems, enable additional services, or make any other changes on the remote systems. This functionality, however, is now available with a combination of the recently introduced Python bridge for Cockpit and the Cockpit Client Flatpak! This allows Cockpit to manage remote systems, assuming only SSH access and that Python is installed on the remote host. Read on for more information on how this works and how to get started.</p>
<p> <span id="more-38635"></span> </p>
<p>If you are not familiar with Cockpit, it is described on the <a href="https://cockpit-project.org/" target="_blank" rel="noreferrer noopener">project’s web site</a> as a web-based graphical interface for servers. Cockpit is intended for everyone, especially those who are:</p>
<ul>
<li><strong>new to Linux </strong>(including Windows admins)</li>
<li><strong>familiar with Linux </strong>and want an easy, graphical way to administer servers</li>
<li><strong>expert admins</strong> who mainly use other tools but want an overview on individual systems</li>
</ul>
<p>You can easily and intuitively complete a variety of tasks from Cockpit. These including tasks such as:</p>
<ul>
<li> expanding the size of a filesystem</li>
<li>creating a network bond</li>
<li>modifying the firewall</li>
<li>viewing log entries</li>
<li>viewing real time and historical performance information</li>
<li>managing Podman containers</li>
<li>managing KVM virtual machines</li>
</ul>
<p>and many additional tasks.</p>
<h2 class="wp-block-heading">Objections to using Cockpit on systems</h2>
<p>In the past, I’ve heard two main objections to using Cockpit on systems:</p>
<ol>
<li>I don’t want to run the Cockpit web server on my systems. Additional network services like this increase the attack surface. I don’t want to open another port in the firewall. I don’t want more HTTPS certificates in my environment to manage and maintain.</li>
<li>I don’t want to install additional packages on my systems. I don’t even have access to install additional packages). The more packages installed, the larger my footprint is, and the more attack surface there is. For me to install additional packages in a production environment, I have to go through a change management process, etc. What a hassle!</li>
</ol>
<p>Let’s address these one at a time. For the first concern, you have actually had several options for connecting to Cockpit over SSH, without running the Cockpit web server, for quite some time. These options include:</p>
<ul>
<li>The ability to set up a bastion host, which is a host that has the Cockpit web server running on it.&nbsp; You can then connect to Cockpit on the bastion host using a web browser.&nbsp; From the Cockpit login screen on the bastion host you can use the <em>Connect to</em><strong> </strong>option to specify an alternate host to login to (refer to the <em>LoginTo</em> cockpit.conf configuration option).&nbsp; Another option is to authenticate to Cockpit on the bastion host, and use the <em>Add new host</em> option.&nbsp; In either case, the bastion Cockpit host will connect to these additional remote hosts over SSH (so only the bastion host in your environment needs to be running the Cockpit web server).</li>
<li>You can use the Cockpit integration available with the upstream <a href="https://theforeman.org/plugins/foreman_remote_execution/1.7/index.html#3.6Cockpitintegration" target="_blank" rel="noreferrer noopener">Foreman</a>, or downstream <a href="https://access.redhat.com/documentation/en-us/red_hat_satellite/6.13/html-single/managing_hosts/index#Host_Management_and_Monitoring_Using_Cockpit_managing-hosts" target="_blank" rel="noreferrer noopener">Red Hat Satellite</a>, to connect to Cockpit on systems in your environment over SSH.&nbsp;&nbsp;</li>
<li>You can use the <a href="https://flathub.org/apps/org.cockpit_project.CockpitClient" target="_blank" rel="noreferrer noopener">Cockpit Client Flatpak</a>, which will connect to systems over SSH.</li>
<li>You can use the <a href="https://quay.io/repository/cockpit/ws" target="_blank" rel="noreferrer noopener">cockpit/ws</a> container image. This is a containerized version of the Cockpit web server that acts as a containerized bastion host</li>
</ul>
<p>For more information on these options, refer to the<a href="https://www.redhat.com/en/blog/connecting-rhel-web-console-part-1-ssh-access-methods" target="_blank" rel="noreferrer noopener"> Connecting to the RHEL web console, part 1: SSH access methods</a> blog post. This blog post focuses on the downstream RHEL web console, however, the information also applies to the upstream Cockpit available in Fedora. </p>
<p>This brings me to the second concern, and the main focus of this article. This is the concern that I don’t want to install additional packages on the remote systems I am managing.  While there are several options for using the web console without the Cockpit web server, all of these options previously had a prerequisite that the remote systems needed to have at least the <em>cockpit-system</em> package installed.  For example, previously if you tried to use the Cockpit Client Flatpak to connect to a remote system that didn’t have Cockpit installed, you’d see an error message stating that the remote system doesn’t have <em>cockpit-bridge</em> installed. </p>
<p>The Cockpit team has replaced the previous Cockpit bridge (implemented using C) with a new bridge written in Python.  For a technical overview of the function of the Cockpit bridge, and how the new Python bridge was implemented, refer to the recent <a href="https://www.youtube.com/watch?v=ZAVUG6E0Xd4" target="_blank" rel="noreferrer noopener">Monty Python’s Flying Cockpit</a> DevConf presentation by Allison Karlitskaya and Martin Pitt. </p>
<p>This new Python bridge overcomes the previous limitation requiring Cockpit to be installed on the remote hosts.  </p>
<h2 class="wp-block-heading">Using the Cockpit Client Flatpak</h2>
<p>With the Cockpit Client Flatpak application installed on a workstation, we can connect to remote systems over SSH and manage them using Cockpit.</p>
<h3 class="wp-block-heading">Installation</h3>
<p>In the following example, I’m using a Fedora 38 workstation. Install the Cockpit Client Flatpak by simply opening the GNOME Software application and searching for Cockpit. Note that you’ll need to have Flathub enabled in GNOME Software.</p>
<figure class="wp-block-image size-large"><a href="https://www.sickgaming.net/blog/wp-content/uploads/2023/08/using-cockpit-to-graphically-manage-systems-without-installing-cockpit-on-them-7.png"><img decoding="async" loading="lazy" width="1024" height="748" src="https://www.sickgaming.net/blog/wp-content/uploads/2023/08/using-cockpit-to-graphically-manage-systems-without-installing-cockpit-on-them.png" alt="" class="wp-image-38636" /></a></figure>
<h3 class="wp-block-heading">Using the Cockpit Client</h3>
<p>Once installed, you’ll see the following when opening the Cockpit Client:</p>
<figure class="wp-block-image size-large"><a href="https://www.sickgaming.net/blog/wp-content/uploads/2023/08/using-cockpit-to-graphically-manage-systems-without-installing-cockpit-on-them-11.png"><img decoding="async" loading="lazy" width="1024" height="570" src="https://www.sickgaming.net/blog/wp-content/uploads/2023/08/using-cockpit-to-graphically-manage-systems-without-installing-cockpit-on-them-1.png" alt="" class="wp-image-38637" /></a></figure>
<p>You can type in a hostname or IP address that you would like to connect to. To authenticate as a user other than the user you are currently using, you can use the user@hostname syntax. A list of recent hosts that you’ve connected to will appear, if this is not the first time using the Cockpit Client. In that case, you can simply click on a host name to reconnect</p>
<p>If you have SSH key based authentication setup, you’ll be logged in to the remote host using the key based authentication. With out SSH keys setup, you’ll be prompted to authenticate with a password. In either case, if it is your first time connecting to the host over SSH, you’ll be prompted to accept the host key fingerprint.</p>
<p>As a special case, you can log into your currently running local session by connecting to <em>localhost</em>, without authentication.&nbsp;&nbsp;</p>
<p>Once connected, you’ll see the Cockpit Overview page:</p>
<figure class="wp-block-image size-large"><a href="https://www.sickgaming.net/blog/wp-content/uploads/2023/08/using-cockpit-to-graphically-manage-systems-without-installing-cockpit-on-them-15.png"><img decoding="async" loading="lazy" width="1024" height="661" src="https://www.sickgaming.net/blog/wp-content/uploads/2023/08/using-cockpit-to-graphically-manage-systems-without-installing-cockpit-on-them-2.png" alt="" class="wp-image-38638" /></a><figcaption class="wp-element-caption">Cockpit overivew menu</figcaption></figure>
<p>Select the <em>Terminal </em> menu item in Cockpit to show that the remote system that I’m logged in to does not have any Cockpit packages installed:</p>
<figure class="wp-block-image size-full"><a href="https://www.sickgaming.net/blog/wp-content/uploads/2023/08/using-cockpit-to-graphically-manage-systems-without-installing-cockpit-on-them-3.png"><img decoding="async" loading="lazy" width="936" height="283" src="https://www.sickgaming.net/blog/wp-content/uploads/2023/08/using-cockpit-to-graphically-manage-systems-without-installing-cockpit-on-them-3.png" alt="" class="wp-image-38639" /></a><figcaption class="wp-element-caption">Cockpit Terminal view</figcaption></figure>
<h2 class="wp-block-heading">Prerequisites for connecting to systems with Cockpit Client</h2>
<p>There are several prerequisites for utilizing Cockpit Client to connect to a remote system. If you are familiar with managing remote hosts with Ansible, you’ll likely already be familiar with the prerequisites. They are the same:</p>
<ol>
<li>You must have connectivity to the remote system over SSH.</li>
<li>You must have a valid user account on the remote system that you can authenticate with.</li>
<li>If you need the ability to complete privileged operations in Cockpit, the user account on the remote system will need sudo privileges.</li>
</ol>
<p>If you are connecting to a remote system that doesn’t have Cockpit installed, there are a couple of additional prerequisites:</p>
<ol>
<li>Python 3.6 or later must be installed on the remote host. This is not usually an issue, with some exceptions, such as Fedora CoreOS which does not include Python by default.</li>
<li>An older version of Cockpit Client can not be used to connect to a newer operating system version. For example, if I installed Cockpit Client on my Fedora 38 workstation today and never updated it, it may not work properly to manage a Fedora 39 or Fedora 40 server in the future.</li>
</ol>
<h2 class="wp-block-heading">Frequently asked questions</h2>
<p>Here are some frequently asked questions about this functionality:</p>
<p><strong>Question:</strong> Cockpit is extendable via additional Applications.&nbsp; Which Cockpit applications are available if I use the Cockpit Client to connect to a remote system that doesn’t have Cockpit installed?</p>
<p><strong>Answer</strong>: Currently, Cockpit Client includes </p>
<ul>
<li><em>cockpit-machines </em>(virtual machine management) </li>
<li><em>cockpit-podman</em> (Podman container management) </li>
<li><em>cockpit-ostree </em>(used to manage rpm-ostree based systems)</li>
<li><em>cockpit-storaged </em>(storage management)</li>
<li><em>cockpit-sosreport</em> (for generating diagnostic reports)</li>
<li><em>cockpit-selinux</em><strong> </strong>(for managing SELinux)</li>
<li><em>cockpit-packagekit</em> (for managing software updates)</li>
<li><em>cockpit-networkmanager</em><strong> </strong>(network management)</li>
<li><em>cockpit-kdump</em> (kernel dump configuration)  </li>
</ul>
<p>The Cockpit team is looking for feedback on what Cockpit applications you’d like to see included in the Cockpit Client. Post a comment below with your feedback. </p>
<p><strong>Question</strong>:&nbsp; I connected to a remote system that doesn’t have Cockpit installed, but I don’t see Virtual Machines or one of the other applications listed in the menu.&nbsp; I thought you just said these were included in the Cockpit Client Flatpak?</p>
<p><strong>Answer</strong>:  When you login to a remote system that doesn’t have Cockpit packages installed, you’ll only see the menu options for underlying functionality available on the remote system.  For example, you’ll only see Virtual Machines in the Cockpit menu if the remote host has the <em>libvirt-dbus</em> package installed. </p>
<p><strong>Question</strong>: Can Cockpit applications available in the Cockpit Client be used with locally installed Cockpit applications on the remote host?  In other words, if I need a Cockpit application not included in the Cockpit Client, can I install just that single package on the remote host?  </p>
<p><strong>Answer</strong>:  No, you cannot mix and match applications included in the Cockpit Client flatpak and those installed locally on the remote host.  For a remote host that has the<strong><em> </em></strong><em>cockpit-bridge</em> package installed, Cockpit Client will exclusively use the applications that are installed locally on the remote host.  If the remote host does not have the <em>cockpit-bridge</em> package installed, Cockpit Client will exclusively use the applications bundled in the Cockpit Client Flatpak.  </p>
<p><strong>Question</strong>:&nbsp; Can I use Cockpit Client to connect to the local host?</p>
<p><strong>Answer</strong>: Yes!  Simply open Cockpit Client and type in <em>localhost</em> and you’ll be able to manage the local host.  You don’t need to have any Cockpit packages installed on the local host if you use this method. You only need the Cockpit Client Flatpak.  </p>
<p><strong>Question:&nbsp; </strong>What Linux distributions can I connect to using the Cockpit Client?</p>
<p><strong>Answer:  </strong>Cockpit is compatible with a number of different Linux distributions.  For more information, see the <a href="https://cockpit-project.org/running.html" target="_blank" rel="noreferrer noopener">Running Cockpi</a>t page.  If connecting to a remote system that doesn’t have Cockpit installed, keep in mind the previously mentioned requirements regarding not connecting to newer OS’s from an older Cockpit Client.  </p>
<p><strong>Question</strong>:&nbsp; Does the Cockpit team have any future plans regarding this functionality?&nbsp;</p>
<p><strong>Answer:  </strong>The Cockpit team is planning on adding the ability to connect to remote hosts without Cockpit packages installed to the <a href="https://quay.io/repository/cockpit/ws" target="_blank" rel="noreferrer noopener">cockpit-ws container image</a>. See <a href="https://issues.redhat.com/browse/COCKPIT-954" target="_blank" rel="noreferrer noopener">COCKPIT-954</a> ticket for more info.  </p>
<p>Have more questions not covered here? Ask them in the comments section below!</p>
<h2 class="wp-block-heading">Conclusion</h2>
<p>The new Python bridge, and the corresponding ability to use the Cockpit Client to connect to remote systems without installing Cockpit, makes it incredibly easy to use Cockpit in almost any circumstance.</p>
<p>Try this out! It’s easy to do. Simply install the Cockpit Client Flatpak, and use it to connect to either your localhost or a remote system. Once you’ve tried it, let us know what you think in the comments below.</p>
</div>


https://www.sickgaming.net/blog/2023/08/16/using-cockpit-to-graphically-manage-systems-without-installing-cockpit-on-them/