How to install Cockpit web console on Ubuntu 22.04

Endrit Qerreti

Endrit Qerreti

Cockpit is a web console utility that allows you to manage your server with ease, it is a essential tool when it comes to managing your server.  

What can you do with Cockpit?

With cockpit you can do basically anything you can do when you login normally on your server, you can manage services, manage logs, create new accounts, update your system and much more, and you can do all this without typing commands manually on your terminal each time you want to do something on your server. So, cockpit is a web-management server gui tool that will save you a lot of time when managing your server.

In this tutorial you will learn how to install Cockpit on Ubuntu 22.04

Step 1 - Login to your Server

Connect to your ssh server

For example: I'm logging in as oht to my server, you can install cockpit on any user you like as long as the user has sudo permissions, because you'll be using cockpit to manage your server.

ssh oht@ip

You can add your user to the sudo group by using  usermod

sudo usermod -aG sudo USER

Step 2 - Update your System

Make sure your system is updated in order to be able to install cockpit. Update your system by using the command below

sudo apt update

Step 3 -  Install Cockpit

Simply run the command below and press enter

sudo apt-get install cockpit

Output:

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  cockpit-bridge cockpit-networkmanager cockpit-packagekit cockpit-storaged
  cockpit-system cockpit-ws cracklib-runtime dconf-gsettings-backend
  dconf-service dns-root-data dnsmasq-base file glib-networking
  glib-networking-common glib-networking-services gsettings-desktop-schemas
  libblockdev-mdraid2 libbluetooth3 libbytesize-common libbytesize1 libcrack2
  libdconf1 libmagic-mgc libmagic1 libndp0 libnl-route-3-200 libnm0
  libpcsclite1 libproxy1v5 libpwquality-common libpwquality-tools
  libpwquality1 libteamdctl0 network-manager network-manager-pptp ppp
  pptp-linux session-migration wamerican wireless-regdb wpasupplicant
Suggested packages:
  cockpit-doc cockpit-pcp cockpit-sosreport xdg-utils udisks2-lvm2 sssd-dbus
  pcscd avahi-autoipd libteam-utils crda wpagui libengine-pkcs11-openssl
The following NEW packages will be installed:
  cockpit cockpit-bridge cockpit-networkmanager cockpit-packagekit
  cockpit-storaged cockpit-system cockpit-ws cracklib-runtime
  dconf-gsettings-backend dconf-service dns-root-data dnsmasq-base file
  glib-networking glib-networking-common glib-networking-services
  gsettings-desktop-schemas libblockdev-mdraid2 libbluetooth3
  libbytesize-common libbytesize1 libcrack2 libdconf1 libmagic-mgc libmagic1
  libndp0 libnl-route-3-200 libnm0 libpcsclite1 libproxy1v5
  libpwquality-common libpwquality-tools libpwquality1 libteamdctl0
  network-manager network-manager-pptp ppp pptp-linux session-migration
  wamerican wireless-regdb wpasupplicant
0 upgraded, 42 newly installed, 0 to remove and 43 not upgraded.
Need to get 12.2 MB of archives.
After this operation, 34.9 MB of additional disk space will be used.
Do you want to continue? [Y/n] y

Next, you'll need to confirm with Yes by pressing Y key and cockpit will get installed.

Step 4 - Enable Cockpit Service

Once cockpit has been installed on your server, you need to enable the cockpit service to ensure cockpit starts automatically when your server boots up.

This is necessary because if your server fails/reboots you won't be able to connect to cockpit without restarting the service manually, so to avoid this from happening enable cockpit service via the command below and cockpit will start automatically always when server turns on.

To enable cockpit service run the command below

sudo systemctl enable --now cockpit.socket

Step 5 - Login to Cockpit

Cockpit runs on 9090 port, to login to Cockpit you need to navigate to your server's Public IP from your browser, simply copy and paste the url below and press enter

http://127.0.0.1:9090

Replace 127.0.0.1 with your server's IP

If for some reason you can't reach the port 9090 , you can open the port on ufw by using

sudo ufw allow 9090

And you should see the Cockpit Login Window

Now simply type your username and password and then click the Login button and you should see the cockpit panel

On the image above I'm logged in as root which has the full access, when you login on a regular user with sudo priveleges you'll need to turn on the administrative access, to do this login to cockpit with the other user and click on the button "Turn on administrative access"

Next, enter the user's password and click "Authenticate"

Now you have administrative access on the user.

If you get an error like "User is not in the sudoers file" when trying to turn on the administrative access make sure you added the user on the sudo group that I mentioned on step 1.

Then logout from cockpit and login again to the same user and the administrative access should be enabled.

Conclusion

By now you should know what cockpit is and how to install it on Ubuntu 22.04.