Three virtual machines nobody could get root on
The script that builds our virtual machines used cloud-init to create exactly one account: the agent’s. That was fine for as long as the agent had permanent sudo, which it did until 2026-11-13. That day I replaced the permanent sudo with the temporary, smart-card-switched kind, and three VMs (the sign-in server, GitLab and the Wi-Fi controller) were left with nobody able to become root on them. The agent couldn’t, by design, and I didn’t have an account on them at all.
Rebuilding three working VMs to add one user seemed excessive, so the agent used virt-customize instead. It’s part of guestfs-tools, runs on the hypervisor, and edits a shut-down VM’s disk directly. For each VM the agent shut it down, added my account (in the wheel group, with my desktop’s public key and an initial password read from a file and set to expire, so I had to change it at first login), a sudoers file for wheel, and the endpoint that the smart-card toggle talks to, then started it again. Each VM was down for between one and three minutes. Nobody in the house noticed, as far as I know.
The lesson is about order. New VMs now get an owner account (or at least the sudo endpoint) from the first boot, and taking permanent access away comes second. I’d thought of the owner account as something to add “later”, and later turned out to be the day it was needed.
A related one from the VLAN cutover: a sudo window opened with the toggle ends when the VM reboots. So root work on a VM goes before restarting it, which is obvious in hindsight and wasn’t at the time.