User Tools

Site Tools


public:managing_luks_on_debian

This is an old revision of the document!


Managing LUKS on Debian

LUKS (Linux Unified Key Setup) is the disk encryption software that's available on Debian. It sits between the file system and the block device, and encrypts all data as it passes through.

Since LUKS works directly on the block device, all commands listed below must be executed as root.

Installing cryptsetup

Cryptsetup is the command used to manage LUKS. You can install it like this:

apt-get install cryptsetup

Creating an encrypted volume

cryptsetup -v --type luks2 luksFormat /dev/DEVICE

You can also create an encrypted volume on a disk image instead. In that case, first create the disk image with a command like the following:

touch disk.img
fallocate -p -v -l 100MiB disk.img

Opening an encrypted volume

cryptsetup luksOpen /dev/DEVICE volumename

The volume should then become available at /dev/mapper/volumename

Closing an encrypted volume

cryptsetup luksClose volumename

Listing slots

Each method that can unlock a disk is stored in a slot, in a header on the LUKS partition. You can list all slots (and other metadata) by issuing the following command:

cryptsetup luksDump /dev/sda3

This would list the slots for disk sda3.

Adding a password slot

You can add an additional password that can unlock the disk by executing:

cryptsetup luksAddKey /dev/sda3

This will add a new password for disk sda3. You will be prompted for an existing password!

Adding a keyfile slot

This method uses a file to unlock the disk. You can add it entirely the same as a new password, with just an additional parameter for the file:

cryptsetup luksAddKey /dev/sda3 /home/keyfile.txt

This will add a new keyfile (located in /home/keyfile.txt) for disk sda3. You will be prompted to authenticate with an existing method!

Adding a Yubikey slot

Clearing a slot

If you want to remove an authentication method, you need to clear the corresponding slot. You can do so by issuing the following command:

cryptsetup -v luksKillSlot /dev/sda3 0

This would clear slot 0 (slots are zero-based) on disk sda3. Note that you will be asked to authenticate with an authentication method stored in another slot.

References

public/managing_luks_on_debian.1722877140.txt.gz · Last modified: by thomas

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki