The infrastructure inventory pings you: a contractor who left the team eighteen months ago is still listed as having received the LUKS recovery passphrase for two production servers. Nothing was lost. The passphrase isn’t necessarily in their head anymore. But it’s in a notebook, an old password manager export, or sitting in an email thread you can’t recall. The compliance question that follows is reasonable — rotate the key, prove it was rotated, and while you’re there, replace passphrase-at-boot with something an operator doesn’t have to manually type at 03:00 when a host reboots. None of this needs downtime.
What’s happening
A LUKS2 volume has up to 32 key slots. Each slot stores an encrypted copy of the master volume key, unlockable by one passphrase or one keyfile. The master key never changes during normal operations — rotating “the LUKS key” actually means adding a new slot, verifying it unlocks the volume, and then removing the old slot. The volume itself stays online and mounted the entire time. The cost of getting this wrong is high: a typo in the new passphrase that you don’t notice until you remove the old one leaves you with a volume you can’t unlock except from a recovery environment. The drill is to always verify the new slot in a controlled way before destroying the old.
Unattended boot is a separate problem. A LUKS volume by default needs a passphrase at boot, which means either typing one at the console (does not scale) or storing the passphrase on the same disk in /etc/crypttab as a keyfile (defeats the encryption). The grown-up answer is NBDE — Network Bound Disk Encryption via clevis and tang. A tang server publishes a public key; clevis binds a LUKS slot to that tang server using a policy (“unlock if tang server X is reachable”). On boot, the host contacts tang, completes a McCallum-Relyea key exchange, and unlocks the disk — without storing the passphrase anywhere on the disk and without manual intervention. The unlock only works on a network the host trusts (typically the management VLAN), so a stolen disk can’t unlock itself on an attacker’s bench.
The combined drill is:
- Add a new strong passphrase to a fresh slot.
- Verify the new passphrase actually unlocks the volume from a recovery context.
- Remove the old slot.
- Optionally bind a slot to a tang server with
clevis luks bind. - Confirm the host boots unattended when tang is reachable, and prompts for the recovery passphrase when it isn’t.
- Generate a
cryptsetup luksHeaderBackupand store it on a different host — losing the header is unrecoverable.
How to verify
Three queries answer “what’s the current encryption state of this disk.”
List slots and their algorithms:
cryptsetup luksDump /dev/nvme0n1p3 | grep -A2 "^Keyslots:"
# Keyslots:
# 0: luks2
# Key: 512 bits
# Priority: normal
# Cipher: aes-xts-plain64
# ...
# PBKDF: argon2id
Slot 0 occupied with a passphrase. If there’s an 8: clevis (sss/tang) slot, the volume is already bound to NBDE.
Check whether a slot can actually unlock without writing data:
cryptsetup open --test-passphrase --key-slot 0 /dev/nvme0n1p3
# (prompts for the passphrase; exit code 0 means slot 0 unlocked successfully)
--test-passphrase makes this safe to run on a mounted production volume. Exit code 0 confirms the slot is good. Any other exit code, and you have a slot that lists in luksDump but does not actually unlock — usually because of a typo when adding it.
Look at the active dm-crypt mapping:
dmsetup status /dev/mapper/root
# 0 419430400 crypt
If dmsetup shows the mapping, the volume is currently unlocked and serving I/O. Rotation never touches this — it only edits header slots.
The fix
The runbook is split in two parts: rotate the passphrase, then bind to tang. Each is independently useful; do both if you’re modernizing a legacy box.
Part 1: rotate the LUKS passphrase
Identify the LUKS device. On a typical RHEL-family install:
lsblk -p -o NAME,FSTYPE,MOUNTPOINT,TYPE
# /dev/nvme0n1p3 crypto_LUKS ... part
# /dev/mapper/root xfs / crypt
Back up the header before doing anything else:
mkdir -p /root/luks-headers
cryptsetup luksHeaderBackup /dev/nvme0n1p3 \
--header-backup-file /root/luks-headers/nvme0n1p3.$(date +%Y%m%d).hdr
chmod 600 /root/luks-headers/*.hdr
Copy that file off the host immediately — to your secrets manager, an offline vault, or both. The header is what makes the disk recoverable if the in-place metadata is ever corrupted.
Add the new passphrase to a free slot:
# luksAddKey will prompt for any existing valid passphrase first, then the new one twice.
cryptsetup luksAddKey --new-key-slot 1 --pbkdf argon2id \
--pbkdf-memory 1048576 --pbkdf-parallel 4 --pbkdf-force-iterations 8 \
/dev/nvme0n1p3
Verify the new slot works without mounting:
cryptsetup open --test-passphrase --key-slot 1 /dev/nvme0n1p3
# Type the new passphrase at the prompt.
# Exit code 0 = slot 1 unlocks correctly.
If --test-passphrase fails for slot 1, do not continue. Re-add it with luksAddKey and re-test.
Once slot 1 verifies, remove slot 0:
cryptsetup luksKillSlot /dev/nvme0n1p3 0
# Prompts for any remaining valid passphrase (slot 1) to authorize the removal.
cryptsetup luksDump /dev/nvme0n1p3 | grep -E "^\s*[0-9]+:"
# Should show slot 1 only.
The volume stays online the whole time — dmsetup status /dev/mapper/root still shows crypt, applications keep reading and writing.
Update the header backup to capture the new state:
cryptsetup luksHeaderBackup /dev/nvme0n1p3 \
--header-backup-file /root/luks-headers/nvme0n1p3.$(date +%Y%m%d.rotated).hdr
chmod 600 /root/luks-headers/*.hdr
Copy off-host.
Rotation is now complete. Document the new passphrase in your secrets manager, audit who has access, and revoke the old passphrase from wherever it was stored.
Part 2: stand up a tang server and bind unattended boot
Tang is a tiny stateless service. It needs one host on the management VLAN (or two for HA) reachable from every encrypted host. We typically run it on the same VM as the bastion or the configuration management server — not on the hosts whose disks it unlocks.
On the tang host:
dnf -y install tang firewalld
systemctl enable --now tangd.socket
firewall-cmd --permanent --add-port=80/tcp --zone=internal
firewall-cmd --reload
Tang listens on TCP 80 by default. Restrict it to the management network at the firewall — anything that can reach tang can unlock disks bound to it.
Confirm tang serves its advertised public keys:
curl -s http://tang.mgmt.example.com/adv | jq .
# {
# "payload": "eyJrZXlz...",
# "protected": "eyJhbGc...",
# "signature": "..."
# }
On each LUKS-encrypted host, bind a free slot to tang:
dnf -y install clevis clevis-luks clevis-dracut clevis-systemd
clevis luks bind -d /dev/nvme0n1p3 tang \
'{"url":"http://tang.mgmt.example.com"}'
# Will prompt for a current valid LUKS passphrase to authorize the new slot.
# Will display the tang server's key fingerprint — verify it matches what
# you got with `tang-show-keys` on the tang host before accepting.
After binding:
cryptsetup luksDump /dev/nvme0n1p3 | grep -A1 "^Tokens:"
# Tokens:
# 0: clevis
# Keyslot: 2
Slot 2 now holds a clevis-bound key. The passphrase from Part 1 stays in slot 1 as the recovery path.
Regenerate the initramfs so the early boot phase has clevis and can talk to tang:
dracut -fv --regenerate-all
The first reboot is the moment of truth. Reboot the host and watch the console — it should reach tang, get the unlock material, and continue booting without typing anything. If tang is unreachable (firewall blocked, tang down, network not yet up), the boot falls back to prompting for the slot 1 passphrase — which is exactly the recovery behavior you want.
For HA, register the same volume against a second tang server with an sss (Shamir Secret Sharing) policy:
clevis luks bind -d /dev/nvme0n1p3 sss '{
"t": 1,
"pins": {
"tang": [
{"url": "http://tang1.mgmt.example.com"},
{"url": "http://tang2.mgmt.example.com"}
]
}
}'
"t": 1 means “any one of the listed tang servers is enough.” "t": 2 would require both — useful for higher-assurance environments where you want to prevent a single tang from unlocking on its own.
Final verification: pull one tang server off the network and reboot the host. Boot should still succeed. Pull both, reboot — boot should hang at the unlock prompt, and the slot 1 passphrase should let an operator recover.
Sanity-check the entire fleet’s state with a one-liner you can run from configuration management:
for h in host1 host2 host3; do
echo "=== $h ==="
ssh "$h" "cryptsetup luksDump /dev/nvme0n1p3 | grep -E 'Slot:|clevis|Cipher'"
done
Every host should have exactly one passphrase slot and one or more clevis slots. Any host with two passphrase slots is a half-finished rotation; any host with no clevis slot is still requiring console intervention at boot.
LUKS rotation and NBDE deployment together are usually a one-time exercise per fleet, but the operational layer — fleet-wide rotation drills, tang server availability, header backup integrity — is recurring. Stack Harbor runs the recurring half under Managed Cloud Ops, with monitoring for tang server health and quarterly key-rotation drills. If your last rotation predates the contractor who left two years ago, request a key-management review.