Disk Encryption (LUKS)
An encrypted host (LUKS2 volume declared in its disko configuration) protects its data in case of theft or disposal, but asks for a passphrase at every boot. DNF industrializes this point of friction with two guarantees:
- several unlocking methods coexist at all times, so losing one method (forgotten passphrase, misplaced YubiKey) never locks you out;
- the boot prompt is answered remotely, from the administration workstation, with no screen or keyboard attached to the host, and that from the very first boot that follows the installation.
Unlock methods
Section titled “Unlock methods”Each method occupies its own keyslot in the LUKS2 header. All of them are valid at the same time, on every encrypted volume of the host.
| Method | Where it lives | Role |
|---|---|---|
| Shared passphrase | sops → luks-passphrase | A single one for the whole fleet, it authorizes keyslot management. It is also what formats the disk |
| Per-host passphrase | sops → luks/<hôte>/passphrase | To hand over to the machine’s user without exposing the fleet |
| FIDO2 YubiKeys | Derived from the physical key | Touch the key at boot, nothing to type |
Provisioning a host
Section titled “Provisioning a host”just luks <host> # provisions (or converges) encryptionjust luks <host> pre # offline half, without touching the machinejust luks <host> passwd # rotates the per-host passphrasejust luks <host> show # audit: keyslot table + compliancejust luks <host> '' <ip> # targets an explicit IP (host not yet resolved)The recipe is idempotent : each run converges and only asks for what is missing. It is called automatically at two moments, and it is rare to have to run it yourself :
| Called by | Action | What it does |
|---|---|---|
just install <host> | pre | Before the build, thus before installation |
just install-here <host> | pre, without a nix account (bootstrap-keys) | First machine, from the ISO |
just configure <host> | (default) | After the first boot |
Without a LUKS volume in disko, it is a logged no-op.
The pre phase never touches the machine. It prepares what must exist
before the system is built :
- the shared passphrase in sops if absent (asked only once for the whole fleet) ;
- the per-host passphrase in sops if absent, randomly generated and without asking anything (see the callout below) ;
- the initrd SSH host key, generated locally and stored in sops
(
luks/<host>/initrd-key, base64-encoded) ; - registering the host in the public manifest
usr/secrets/luks.json(versioned in the clear, it contains no secret) : it is this entry that activates the module.
The default phase adds what requires the machine :
- re-lays the initrd key from sops if it is missing on the target (it never regenerates a new one, that would invalidate the one placed by the installation) ;
- on a gateway, records its public address in the manifest
(fallback of
just unlock, see below). It is only a backup : the gateway reports its own address to the HCS. Behind a box, the WAN interface only carries a private IP : the public address is the one used to reach the machine, or is passed as an argument (just luks <host> '' auto <IP or DDNS name>) ; - if no managed passphrase unlocks the volume (host installed before the switch to shared formatting), asks for its installation passphrase one last time and enrolls the shared one along with it.
Then commit and deploy :
git add usr/secrets/luks.jsonjust commit "system(luks): <host>"just apply <host>At deployment, two idempotent services converge the LUKS header on each
apply: luks-passphrase-sync (shared and per-host passphrases) and
yubikey-luks-enroll (one FIDO2 entry per YubiKey enrolled on the fleet, see
Strong authentication).
Passphrase rotation
Section titled “Passphrase rotation”- Per host:
just luks <hôte> passwd, then commit and apply. The old keyslot is removed and replaced on the next deployment. - Shared: edit
luks-passphraseviajust sops, then apply across the whole fleet: each encrypted host rotates its keyslot in the process. - Isolated host:
just luks <hôte> passwd, machine booted. Rotation happens on the spot, without apply (see Isolated encrypted host).
The synchronization service detects changes through a local ledger
(/var/lib/luks-passphrase/ledger) : a modified sops value
enrolls the new passphrase then kills the old slot. Slots missing from
the ledger (FIDO2, manual enrollments) are never touched.
Isolated encrypted host
Section titled “Isolated encrypted host”An isolated host holds no fleet secret, nor does its encryption :
| Item | Isolated host |
|---|---|
| Keyslots | Its passphrase, its YubiKeys, no shared one |
| Formatting | With its passphrase |
luks/<hôte>/* | usr/secrets/hosts/<hôte>.yaml |
| YubiKeys | At the host’s salt, once captured |
just unlock | Sends only its passphrase |
| Rotation | just luks <hôte> passwd, immediate |
Without a synchronization service, passwd acts on the machine itself :
new slot, sops, then removal of the old one. At every step, the value
stored in sops opens the volume.
Each key there is enrolled to a salt specific to the host, authorized by its passphrase : see Isolated encrypted hosts and YubiKey, salts and isolated hosts.
A host that becomes isolated is reinstalled (just install) : its old
luks/<hôte> entries remain in secrets.yaml, flagged by just luks,
to be deleted with just sops.
Unlocking at boot
Section titled “Unlocking at boot”Every encrypted host follows the same sequence, with nothing to configure:
- YubiKey — an enrolled and plugged-in key makes its LED blink: touching it opens the volume, nothing to type. No key plugged in, the step lasts ~6 s ; a key that nobody touches, ~30 s (firmware limit).
- Passphrase — a prompt is then presented, with no time limit. It accepts the per-host passphrase, the shared one or the installation one.
The prompt of step 2 is one and the same request, served in parallel
on the physical console (/dev/tty1) and over ssh on port 2222. Nothing to
choose, no window to miss: the first one to answer opens the volume.
Remotely, the initrd starts a dedicated sshd on port 2222, with its
own persistent host key, accessible only with the deployment key nix.
just unlock answers it there :
just unlock <host> # passphrase read from sops, otherwise asked at the terminaljust unlock waits for port 2222 to appear (a dot per attempt), reads
the shared passphrase from sops and pushes it into the initrd, then verifies
that the machine has indeed left its initrd before announcing success. If it is
refused, it retries with the per-host passphrase. This is what
just full-install calls on its own after the first reboot. On a non-encrypted
host, it is a logged no-op.
Before any sending, just unlock verifies that the initrd host key is
the one stored in sops, then enforces it on each connection. Key absent from
sops or different → stop, nothing is sent : an impostor could listen on 2222.
No stored passphrase accepted, or no infrastructure key on the
workstation : from a terminal, just unlock presents the LUKS prompt via
systemd-tty-ask-password-agent. It probes port 2222 on the explicit IP (if
provided), the host name, the WAN IP reported to the HCS, then that of the
manifest. In both cases, once the passphrase is accepted, the boot continues and
port 22 comes back.
WAN address of gateways
Section titled “WAN address of gateways”A gateway that reboots may come back on a different public address,
awaiting its passphrase and without VPN. It therefore reports its address to
the HCS, over SSH, and just unlock tries it first, before the manifest one.
| Moment | Who reports | Frequency |
|---|---|---|
| Waiting in initrd | dnf-wan-report (initrd) | Every 15 min |
| System booted | dnf-wan-report.timer | At boot, then every hour |
On the HCS side, the dnf-wan-report account accepts only one key per gateway
(its initrd key, tied to a forced command). The retained address is the one seen
by sshd, stored in /var/lib/dnf-wan-report/<host>.
Bringing it into service, in this order :
just luks <gateway>copies the initrd public key intousr/secrets/luks.json(nothing activates before) ;git add usr/secrets/luks.json, thenjust apply <hcs>;just apply <gateway>, thenjust luks <gateway> showconfirms the first report.
Each change of address or phase (initrd, system) is logged on
the HCS : journalctl -t dnf-wan-report retraces the reboots of
each gateway there.
Verifying a host
Section titled “Verifying a host”just luks <host> show writes nothing : it queries the machine and reports.
It exits with an error as soon as a check fails, so it can also be used
in a script.
just luks <host> showA first block draws up the keyslot table of each volume. Nothing is assumed there : each managed passphrase is really tried against the header, so the “Check” column says what the volume accepts today, not what a registry has remembered.
/dev/disk/by-partlabel/disk-main-luks Slot Content Source Check ---- ------------------- --------------------------- ----------------- 0 Shared passphrase sops luks-passphrase opens the volume 1 Host passphrase sops luks/poste/passphrase opens the volume 2 YubiKey alice/main systemd-fido2 token enrolled 7 Unknown - not managed by DNF Slots in use: 4/32A second block audits remote unlocking, point by point :
| Check | What it catches |
|---|---|
Host present in luks.json | The module would stay inert |
| Initrd key on the target (+ fingerprint) | Next apply without remote unlocking |
| sops backup of the same fingerprint | A reinstallation would lose remote access |
| initrd sshd enabled in the configuration | nix.pub missing, or host outside the manifest |
| Bootloader newer than the key | The trap : key absent from the initrd that boots |
| Drivers of the wired cards present in the initrd | No network in stage 1 : nothing answers on 2222 |
| Booted system = audited configuration | A pending apply would make the audit misleading |
| WAN address reported to the HCS (gateways) | Report missing or older than 2 h |
| Public address collected (gateways) | Unreachable in initrd once the VPN is down |
Under the hood
Section titled “Under the hood”| Location | Content | Status |
|---|---|---|
usr/secrets/luks.json | Provisioned hosts, WAN IP, initrd public keys | Public, versioned |
secrets.yaml → luks-passphrase | Shared passphrase of the fleet | sops encrypted |
secrets.yaml → luks/<host>/passphrase | Per-host passphrase | sops encrypted |
secrets.yaml → luks/<host>/initrd-key | initrd SSH host key (base64) | sops encrypted |
secrets.yaml → luks/<host>/initrd-key-pub | Its public key, pinned by just unlock | sops encrypted |
/var/lib/luks-initrd/ (target) | Working copy of the initrd key | Persistent, outside the repo |
/var/lib/luks-passphrase/ledger (target) | Registry of managed keyslots (rotation detection) | Persistent, outside the repo |
/var/lib/dnf-wan-report/<host> (HCS) | Last reported WAN address | Persistent, outside the repo |
The module exposes three options: darkone.system.luks.enable (default true),
darkone.system.luks.sshPort (default 2222) and
darkone.system.luks.wanReport.enable (default true).
Machine without DNS after unlocking?
Section titled “Machine without DNS after unlocking?”The initrd takes a DHCP lease for port 2222. Kept at boot, NetworkManager
sees the interface as connected (externally): no DHCP, no DNS, resolv.conf
empty. The initrd now returns its lease on a NetworkManager host: effective at
the first reboot after deployment.
See also
Section titled “See also”- Strong authentication (YubiKey): enrollment of physical keys, including the LUKS FIDO2 part
- Secrets management: sops, age keys and rotation
- The Justfile: reference for the
luks,enterandconfigurerecipes