mullane.info

Back from the trip, part one: a card that never worked, and firmware settings without a screen

2026-11-28 · common

I got back from a week away to a network that had been through two power outages while I was gone, plus a pile of small things I’d changed on my laptop while travelling. The laptop (laptom) is the agent’s second seat, so the first job was making sure it and my desktop (desktom) agreed on everything. They mostly did. The laptop was level with our GitLab in every repo; the desktop, which had been switched off the whole time, was behind in nine of them, all clean, so they fast-forwarded. The one wrinkle was the secrets folder, which isn’t in git and gets copied between the two by hand. The laptop had made two new files on the trip, so the agent compared both directions before copying anything (a plain one-way copy from the desktop would have been the wrong call), brought those two across without overwriting anything, and left alone a stray file from before the laptop was even a seat (I deleted it).

The second card that never worked

Before the trip I’d set up a second smart card, cardtom1, as the spare for cardtom0. It’s what turns on the agent’s temporary root across the fleet, and it does the same for the firewall through a separate account, agent-elevate, whose only key login runs one fixed command. Our hand-off notes said both cards had been verified everywhere. I changed cardtom1’s PIN tonight, checked fleet-sudo against every host, and the firewall refused it: Permission denied (publickey,password,keyboard-interactive).

The obvious suspects didn’t hold up. A new PIN doesn’t change the key, and every other host accepted the card, so the client side was fine. With cardtom0 I opened an elevation window, and the agent read the user’s config through the API: both card keys were there, same forced command, no stray characters. Then it read the firewall’s own SSH log, which settled it. Every successful agent-elevate login since the 17th had come from cardtom0. The one cardtom1 attempt on the 25th (my “verification”) had been refused exactly like tonight’s. It had never worked.

The cause turned out to be a detail of OPNsense’s user API. Saving a user writes config.xml, but the step that writes the key file in the account’s home directory only runs when the save includes the user’s name field. The agent had added cardtom1 with a partial save (just the keys), so the config was right and the file on disk never changed. Two more “harmless” re-saves tonight didn’t help either, for the same reason. The giveaway, once you know to look, is that the system log never showed the user_changed line for that account after the change. A save with the name included, and my next fleet-sudo status opnsense with cardtom1 came back “on”. It’s now a small user-sync command in our OPNsense tool, so the next key change is one line instead of an evening.

Retiring the old shared VLAN

When we split the household network into one VLAN per person a week ago, the old shared one (USERS) stayed around as a rollback until the 28th. That was today, so it went: the UniFi network and its switch port profile first (nothing used them, and the switches took the change without dropping a client), then, in the same elevation window as the card fix, the firewall interface, its VLAN device, a leftover alias, and the retired row in our plan’s CSV. The firewall re-applied cleanly, and the agent checked internet and DNS from five zones afterwards. A week of rollback for a cutover that never needed it seems about right.

Onboarding video

video is the box that runs Jellyfin for the mediarr setup, and it had never been brought into the fleet properly. I’d left its password in a file and gave the agent the login user and the host key fingerprints I’d accepted months ago; the keys it saw tonight matched. It ran the bootstrap as me with that password, and made two small mistakes along the way, which it owned up to. The first run left out the laptop’s key, because the bootstrap script only adds it if the file sits next to the script and the skill’s copy command didn’t include it (fixed in both). And when it tried to use my password to turn on its own temporary sudo, its permission check refused, which is the check doing its job; I ran the toggle myself. After that it was the usual list: a full upgrade (the package database was two months old), time from the firewall, packages through the mediarr cache, weekly updates reporting to the monitoring server, the fleet-sudo endpoint, a Wazuh agent. One surprise: the box had no Python at all, which our root tools assume. I kept my own password login as a fallback, and Jellyfin keeps mediarr’s certificate, since it’s part of that suite.

Firmware settings without a screen

The real lesson of the trip was that three machines (the GitLab host svchost0, the security box netsec, and video) stayed off after a power cut until someone pressed a button, and monitor had once done the same. The fix is a firmware setting, “Restore on AC power loss”, and I have no spare monitor or keyboard I can easily move to where they live. So I asked whether it could be done from Linux.

A research session went through all of them read-only and came back with a no: generic AMI firmware, no firmware settings in sysfs, no vendor tool, no IPMI, no Intel AMT. But the setting ends up in a chipset register (GEN_PMCON_A on the Intel box, PM register 0x5B on the AMD ones) that lives in the RTC well, survives the outage, and gets rewritten from the firmware’s setting at every boot. So the OS can’t change the firmware, but it can overwrite the register after the firmware has had its say, at every boot, and whatever the running OS left there is what the machine does when power comes back. It also found two things we’d recorded wrong. netsec’s Wake-on-LAN test a few days earlier had gone to its bridge’s software MAC address rather than the network card’s (a card only wakes on its own), so it proved nothing. And monitor’s firmware turned out to be set to “previous state”, which is why it came back after both outages this week: it was running each time.

I went with the register script. It’s in common/ac-power now: a small tool that refuses any chipset it hasn’t been checked against and any register value that looks wrong, and a unit that runs it early at every boot. The agent read each machine before changing it (svchost0, netsec and video all said “stay off”, monitor “previous state”), applied it in order of how easily each could be recovered (svchost0 first, since it at least wakes from a magic packet), and armed Wake-on-LAN on each physical port while it was at it. Nothing in firmware storage is touched, so the worst a bad write could do is hang a running machine until someone power-cycles it, which is why I wanted to be home for it.

That’s part one. None of this counts as working until I’ve pulled the plug on each machine for half a minute and watched it come back by itself, which is tomorrow’s job. So is sorting out which outlets on our two UPSes feed what (the first one turns out to be running at 6 % load, so it’s outlets I’m short of, not watts), and finding out whether the many containers spread across these hosts are actually getting updates. I have a feeling some of them aren’t.