2

My LUKS encrypted drive has 3 passphrases. Two of them are secure (and long), the other one is lost. However, I dimly remember that it was not up to par; it was used during experiments and should have been wiped afterwards. How can I get rid of that key, given I do not know it anymore, but at least the other two?

4

The magic option is luksKillSlot.

The point is to figure out which of your three keyslots contains the key to be deleted. If you don't know it yet, you can check this out by trying all the known keys one after another and let cryptsetup tell you which key refers to which slot. The unknown key then refers to the remaining slot.

Check which slots are used (in my case slots 0, 1, and 2 are used). Replace /dev/sdb4 with your actual device:

root@host:~# cryptsetup luksDump /dev/sdb4
LUKS header information for /dev/sdb4
...
Key Slot 0: ENABLED
...
Key Slot 1: ENABLED
...
Key Slot 2: ENABLED
...
Key Slot 3: DISABLED
Key Slot 4: DISABLED
Key Slot 5: DISABLED
Key Slot 6: DISABLED
Key Slot 7: DISABLED

Now open (=decrypt) your device with your first key and let cryptsetup be verbose so it shows which slot was used to unlock the device:

root@host:~# cryptsetup -v open --type luks /dev/sdb4 someAlias
[enter one of your two known keys]
Key slot 2 unlocked.
Command successful.

Remember which slot (2 in this case) the first key refered to and undo the step:

root@host:~# cryptsetup close someAlias

Repeat with your second known key:

root@host:~# cryptsetup -v open --type luks /dev/sdb4 someAlias
[enter the second of your two known keys]
Key slot 0 unlocked.
Command successful.
root@host:~# cryptsetup close someAlias

Now you know that the two known keys refer to slot 2 and slot 0. So slot 1 must be the one that contains the unknown key. Delete it with:

root@host:~# cryptsetup -v luksKillSlot /dev/sdb4 1
Keyslot 1 is selected for deletion.
Enter any remaining passphrase: 
[enter one of the two known keys]
Key slot 0 unlocked.
Command successful.

Check it out:

root@host:~# cryptsetup luksDump /dev/sdb4
LUKS header information for /dev/sdb4
...
Key Slot 0: ENABLED
...
Key Slot 1: DISABLED
Key Slot 2: ENABLED
...
Key Slot 3: DISABLED
Key Slot 4: DISABLED
Key Slot 5: DISABLED
Key Slot 6: DISABLED
Key Slot 7: DISABLED
| improve this answer | |
  • Yes, luksKillSlot was what I had overlooked. However, I could not play with opening the device (is always open). Luckily, luksKillSlot will ask for a remaining passphrase, so I could go one by one. – MPi Mar 14 '19 at 9:58
  • @MPi Nice to hear and thank you for your vote. If the device was already opened, you maybe could have issued cryptsetup close someAlias first. – PerlDuck Mar 14 '19 at 21:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.