Skip to content

Passphrases and Key Slots

Outcome: a vault with a second passphrase added, one passphrase changed, and one slot killed — each verified as it lands. Every operation in this chapter ran for real in the lab; the transcripts are t02, t03 and t09. None of them touches the data. That is the master-key design of chapter 2 paying off: slot operations rewrite a few hundred kilobytes of header, never the vault's contents.

The rules of the house

Three rules govern everything below, and the lab ran into each one:

  1. Every change needs a key that already works. Adding, changing or killing a slot starts by unlocking with an existing passphrase or key file. There is no administrative override. This is why losing the last working key is final (chapter 15).
  2. A wrong unlocking passphrase changes nothing. The attempt fails before any write. The lab's record of it is even instructive about the tool's manners: --test-passphrase says No key available with this passphrase. and exits 2, while luksAddKey given a wrong unlocking key exits 2 and says nothing at all (t03). Exit codes are the contract; messages are a courtesy.
  3. Slots are numbered and finite. LUKS1: 0–7. LUKS2: 0–31. When the lab asked for slot 32 the answer was the specification in one line — Key slot 32 is invalid, please select between 0 and 31.

Adding a passphrase

With one working passphrase in pass1.txt, a second joins it:

cryptsetup luksAddKey \
  --key-file pass1.txt vault.img

Interactively, cryptsetup then asks for the new passphrase twice. The lab's second passphrase — second key opens the side door — landed in slot 1, and the dump afterwards showed the two slots side by side, each with its own Argon2id calibration (time cost 12 for slot 0, 29 for slot 1: the calibration is measured fresh each time, against a machine whose mood varies). Either passphrase now opens the vault; the lab proved slot 1 with --test-passphrase (t02).

Why would you want two? The classic reasons: a spare passphrase kept somewhere safe, against the day the main one is forgotten; a shared device where each person has their own, so one person's departure is one slot's funeral, not a re-keying of the world; and rotation, where the new passphrase is added and proven before the old one is killed, so the vault is never one typo away from being sealed forever. That ordering — add, prove, then kill — is the whole of safe key handling in one sentence.

Changing a passphrase

cryptsetup luksChangeKey \
  --key-file pass2.txt vault.img

This finds the slot that pass2.txt unlocks and rewraps it with a new passphrase. The lab changed slot 1 to a third passphrase and then proved both halves of the claim: the new one passed --test-passphrase, the old one was refused with No key available (t03). Note what did not happen: the master key, the data, and slot 0 were all untouched. A "passphrase change" in LUKS is a slot change wearing a friendly name.

Killing a slot

Two tools, two intentions:

cryptsetup luksKillSlot \
  --key-file pass1.txt vault.img 2
cryptsetup luksRemoveKey \
  --key-file pass3.txt vault.img

luksKillSlot kills by number. You name the slot; any other working key authorises the execution. Use it when you know exactly which slot must die — the lab used it to remove an accidentally duplicated slot 2, and later to retire the slot-31 experiment of transcript t09.

luksRemoveKey kills by identity: give it a passphrase (or key file) and it finds and destroys the slot that passphrase opens. Use it when the passphrase itself is the thing being retired and you may not remember its number.

Both are permanent in the strong sense. The slot's wrapped key copy is overwritten through its 4000 anti-forensic stripes (chapter 4), so the destroyed passphrase does not linger in recoverable bytes. And both will let you kill the last slot if you insist — try it only on practice vaults; on a real one, that command is the sound of a door locking from the inside.

Choosing passphrases that deserve slots

The two-second Argon2 stretch (chapter 2) prices each guess, but a passphrase drawn from a small space still falls: a dictionary word falls to a dictionary, a pet's name to an afternoon of trying variations. The arithmetic that defends you is length and unpredictability multiplied — the standard advice is a passphrase: several unrelated words, memorable as a sentence, useless as a guess. The lab's fixtures are deliberately weaker than yours should be; they were chosen to be typed into transcripts, and a stolen lab file teaches an attacker nothing about your vault because your vault's slots hold your words. One more rule with teeth: a passphrase reused from anything else — an email account, a forum — inherits every breach that other thing ever suffers. Slots are cheap. Give the vault its own words.