Via Cà Matta 2 - Peschiera Borromeo (MI)
+39 02 00704272
info@synaptica.info

How to Configure Cockpit to Manage VMs on Ubuntu

Digital solution partner

How to Configure Cockpit to Manage VMs on Ubuntu

<header>
<h1>How to Configure Cockpit to Manage VMs on Ubuntu</h1>
<p><em>In this guide, you will learn how to install and configure Cockpit to manage virtual machines (VMs) on an Ubuntu KVM host.</em></p>
</header>

<section>
<h2>Introduction</h2>
<p>Cockpit is an easy-to-use web interface that allows you to manage Linux servers. It is particularly useful for monitoring and administering virtual machines (VMs) on a KVM host. In this guide, we’ll walk you through how to install and configure Cockpit on an Ubuntu system to manage your VMs simply and effectively.</p>
</section>

<section>
<h2>Prerequisites</h2>
<ul>
<li>An Ubuntu server with KVM already installed</li>
<li>Root access or <code>sudo</code> privileges</li>
</ul>
</section>

<section>
<h2>Installation Steps</h2>

<h3>1. Update the System</h3>
<p>It’s always a good practice to update the system first:</p>
<pre><code>sudo apt update && sudo apt upgrade -y</code></pre>

<h3>2. Install Cockpit</h3>
<p>To install Cockpit on Ubuntu, run the following command:</p>
<pre><code>sudo apt install cockpit -y</code></pre>

<h3>3. Enable and Start Cockpit</h3>
<p>Once Cockpit is installed, enable and start it with:</p>
<pre><code>sudo systemctl enable –now cockpit.socket</code></pre>

<h3>4. Configure the Firewall</h3>
<p>Open port 9090, which is necessary to access the Cockpit web interface:</p>
<pre><code>sudo ufw allow 9090</code></pre>

<h3>5. Install the VM Management Add-on</h3>
<p>Cockpit offers an additional module for managing virtual machines. Install it with:</p>
<pre><code>sudo apt install cockpit-machines -y</code></pre>

<h3>6. Access the Cockpit Web Interface</h3>
<p>You can now access Cockpit via your browser. Enter the server’s IP address followed by port 9090:</p>
<pre><code>https://<strong>&lt;your-server-ip&gt;</strong>:9090</code></pre>
<p>Log in using your system credentials (those of a user with <code>sudo</code> privileges).</p>
</section>

<section>
<h2>KVM Configuration</h2>
<p>Ensure that KVM is installed and properly configured on your Ubuntu server.</p>

<h3>1. Install KVM and Related Packages</h3>
<p>If KVM is not already installed, run the following command:</p>
<pre><code>sudo apt install qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils -y</code></pre>

<h3>2. Start and Enable the libvirtd Service</h3>
<p>The <code>libvirtd</code> service manages VMs. Start and enable it with:</p>
<pre><code>sudo systemctl enable –now libvirtd</code></pre>

<h3>3. Add Your User to the Necessary Groups</h3>
<p>To ensure that your user can manage VMs without issues, add it to the <code>libvirt</code> and <code>kvm</code> groups:</p>
<pre><code>
sudo usermod -aG libvirt $(whoami)
sudo usermod -aG kvm $(whoami)
</code></pre>

<p>After this, you’ll need to log out and log back in to apply the group changes, or you can reboot the system.</p>
</section>

<section>
<h2>Managing Virtual Machines with Cockpit</h2>
<p>Now that Cockpit is installed and configured, you can start managing your virtual machines. Navigate to the “Virtual Machines” section within the Cockpit web interface. Here, you can create, start, stop, and monitor VMs easily.</p>
</section>

<footer>
<p>With this guide, you have successfully set up Cockpit on Ubuntu to manage VMs. If you encounter any issues, feel free to reach out or leave a comment below!</p>
</footer>