Get root on the server
The server in your project is yours, and so is root on it. You rarely need it: the portal’s operations run through pbx-agent and need no shell. This page is for the times you do, such as reading logs the portal cannot show, or running the cluster without PaaSbox, and for closing the way again afterwards.
How the server is set up
Section titled “How the server is set up”- The node image runs an SSH server that accepts root with a key only. There are no passwords on the image.
- The portal adds no SSH key when it creates the server, and the cluster’s firewall keeps port 22 closed.
- Root’s keys are read from
/etc/ssh/authorized_keys.d/root. That file survives reboots and upgrades;/rootdoes not.
Hetzner’s web console is not a way in. It needs a root password, and the image sets none.
What you need
Section titled “What you need”- Your SSH public key.
- The public address you work from.
- For the first way: an admin kubeconfig (Get a kubeconfig) and
kubectl. - Access to the cluster’s project in the Hetzner console.
Add your key through the cluster
Section titled “Add your key through the cluster”Use this while the cluster runs.
-
Start a pod on the node that sees the server’s file system. The node is named after the cluster’s DNS label, such as
upcheck-prod-cp-1:Terminal window kubectl debug node/upcheck-prod-cp-1 -it --profile=sysadmin --image=busybox--profile=sysadminruns the pod privileged, the way the lab’s pod on the node ran. -
Add your key. Inside the pod, the server’s file system is at
/host. Put your own public key between the quotes:Terminal window mkdir -p /host/etc/ssh/authorized_keys.decho 'ssh-ed25519 AAAA... you@laptop' >> /host/etc/ssh/authorized_keys.d/rootexit -
Delete the debug pod.
kubectl get podsshows it; its name starts withnode-debugger-.Terminal window kubectl delete pod <its name> -
Open port 22 for your address with a firewall of your own. In the Hetzner console, under Firewalls, create a firewall with one inbound rule, TCP port 22 from your address (such as
203.0.113.7/32), and apply it to the server. Do not add the rule to the cluster’s own firewall: the portal writes that one’s rules again whenever the API ranges are saved (Change who can reach the API). -
Log in.
Terminal window ssh root@<the server's IPv4>
Use Hetzner’s rescue system
Section titled “Use Hetzner’s rescue system”Use this when the cluster does not run, or before pbx-agent ever enrolled. The rescue system is a Linux that Hetzner boots from the network instead of the server’s disk, with the disk attached. The server reboots for it, so the cluster and your apps are down while you work in it.
-
Open port 22 for your address with a firewall of your own, as in step 4 above. The cluster’s firewall applies to the rescue system too.
-
In the Hetzner console, open the server’s Rescue tab, choose your SSH key and enable the rescue system; it takes effect with the next start, so power-cycle the server.
-
Log in with
ssh root@<the server's IPv4>. The server’s disk is attached but not mounted;lsblklists it. -
When you are done, reboot. Hetzner uses the rescue system for one start only, so the server boots the node image again, and k3s and
pbx-agentstart on their own.
Close it again
Section titled “Close it again”- Close port 22. Remove your firewall from the server in the Hetzner console, or delete it. A delete of the cluster does not remove it: it carries no label of the cluster’s.
- Remove your key. The image only ever adds keys. Delete your line from
/etc/ssh/authorized_keys.d/root, over SSH before you close the port, or through a debug pod as above.
What to keep in mind on the server
Section titled “What to keep in mind on the server”- The portal never connects to the server, and nothing you do there goes through it.
- What you change by hand on the server is yours to answer for (How it works).
- Do not edit the image’s own files in
/etc./etcis an overlay kept on the persistent/var: a file changed there shadows every later image’s version of it, for good. Put a k3s setting of your own into a drop-in of your own, such as/etc/rancher/k3s/config.yaml.d/60-mine.yaml; the50-pbx-*.yamldrop-ins belong topbx-agent, which writes them again.