Last week, we looked at installing and configuring Cockpit on a single host. In Part 2 of this tutorial series, we shall look at how to add a second (or more) hosts so they are all visible from the original instance.
Cockpit is installed and functioning on the original host from Part 1 – which we will now refer to as host0. We will now add a second host, unsurprisingly called host1, so that we have the same access from within the original web service.
For additional hosts, Cockpit communicates over SSH so we shall be using authorized keys as the mechanism to login to the second host. It stands to reason therefore that you also need a user account on the second server.
Once again, installing Cockpit is simple with apt. Note that we do NOT need the web services package so we can omit that by not installing the meta package just installing the ones we do need.
root@host1:~# apt-get install cockpit-system cockpit-storaged cockpit-networkmanager
Firstly, make sure that there is an ssh key generated for the user you are connecting to Cockpit with. Usually this is found in ~/.ssh/id_rsa.pub If there is then skip ahead, otherwise generate one.
If you have not already done so, copy this key to host1.
root@host0:~# ssh-copy-id -i ~/.ssh/id_rsa.pub root@host1
In the web interface, check that your key is enabled by selecting
Authentication from the user menu in the top right of the page and making sure the toggle is on.
All that remains is to go to the Dashboard page and add the host.
After which you should see both servers in the dashboard, and can drill deeper on either.
In the last part of this series, I will show how to put Cockpit behind a reverse proxy so that you can serve it on a default port on a host which already has NGINX installed.