It's simple.

file

Install

First:

sudo apt install cockpit -y

Authentication

Ensure you have a user instead of root is in the sudo group.

Please follow the instructions from: Best practice for authentication

Fix network issue

You may see the following error after installation:

packagekit cannot refresh cache whilst offline

First go to here:

cd /etc/netplan/

Create a new profile:

sudo touch /etc/netplan/49-set-nm-renderer-for-cockpit.yaml

Edit it as content:

sudo vim /etc/netplan/49-set-nm-renderer-for-cockpit.yaml
network:
  version: 2
  renderer: NetworkManager

Move other profiles to bigger number. For exmaple, move ./00-installer-config.yaml to ./50-installer-config.yaml.

sudo mv ./00-installer-config.yaml ./50-installer-config.yaml

Apply net plan:

sudo netplan apply

Restart related services:

sudo systemctl restart cockpit

Install navigator plugin

sudo apt install -y jq
latestUrl=$(curl https://api.github.com/repos/45Drives/cockpit-navigator/releases/latest | jq -r '(.assets[] | select(.browser_download_url | contains(".deb"))).browser_download_url')
echo "Latest download url is $latestUrl"
wget -O /home/anduin/install.deb $latestUrl
sudo dpkg -i /home/anduin/install.deb
rm /home/anduin/install.deb

Try cockpit on your browser!

Open browser, open: https://host:9090. Ignore cert issues.

file

Ensure HTTPS

By the way, you may need Caddy to reverse proxy the cockpit server.

Install caddy:

cat /etc/apt/sources.list.d/caddy-fury.list | grep -q caddy || echo "deb [trusted=yes] https://apt.fury.io/caddy/ /" | sudo tee -a /etc/apt/sources.list.d/caddy-fury.list
sudo apt update
sudo apt install -y caddy

You can follow practice here: Caddy Tips

Example:

# Manual 2FA.
jump.aiursoft.cn {
	basicauth / {
		anduin $2a$12$HHHHHHHHAAAAASSSSSSSSHHHHHHHHH
	}
	reverse_proxy https://jump:9090 {
		transport http {
			tls_insecure_skip_verify
		}
	}
}