2.8 KiB
2.8 KiB
LPIC-3 331.3: Encrypted file systems
LUKS on a spare disk: key slots, a key file, the LUKS1 to LUKS2 conversion, unlocking at boot from crypttab, network-bound unlocking with Clevis and Tang, and an eCryptfs private directory.
Before you start
The lab adds a spare disk, /dev/loop40 (512 MiB, empty). It's an image
file under /var/lib/le-lab/disks/, attached again at every boot, before
crypttab is read.
The peer, at 10.99.0.2 (name peer), stands in for the other VM and
already runs a Tang server on its port 80 (le-lab-peer-tang.socket):
curl http://10.99.0.2/adv shows its advertisement.
On Ubuntu, the lab also creates the user crypto (password Lab-Pass-1)
for task 5.
Tasks
- Install
cryptsetupif it's missing. Format/dev/loop40as LUKS1 with the passphraselab-pass-one, open it assecret, make an ext4 file system on it, mount it on/mnt/secret, and writetop secretto/mnt/secret/note.txt. - Add a 64-byte random key file,
/root/secret.key(mode 400), to a second key slot. Then close the volume and convert it to LUKS2. - Unlock and mount the volume at boot the way the system does it: a
crypttab entry
secretthat names the volume by UUID and uses the key file, and an fstab entry that mounts/dev/mapper/secreton/mnt/secret, both withnofail. Start it through systemd and check thatnote.txtis there. - Install Clevis with its LUKS support, and bind the volume to the Tang
server at
http://10.99.0.2, so thatclevis luks unlockopens it with no passphrase while Tang is reachable. The passphrase must still work. - Ubuntu: set up an eCryptfs private directory for
crypto, wrapped with their login passwordLab-Pass-1, that doesn't mount automatically at login. Mount it ascrypto, writeprivate datato~/Private/diary.txt, and unmount it again.
Hints
cryptsetup luksFormat --type luks1,cryptsetup open,cryptsetup status;echo -n 'lab-pass-one' | cryptsetup ... -reads the passphrase from standard input.dd if=/dev/urandom bs=64 count=1,cryptsetup luksAddKey,cryptsetup luksDump,cryptsetup convert --type luks2(the volume must be closed).cryptsetup luksUUID; a crypttab line is name, device, key file, options.systemctl daemon-reload,systemctl start [email protected],mount /mnt/secret.clevis luks bind -d DEVICE tang '{"url":"http://10.99.0.2"}',clevis luks list;clevis luks unlock -d DEVICE -n NAMEneeds the volume closed first.ecryptfs-utils,modprobe ecryptfs;su - crypto -c "ecryptfs-setup-private --nopwcheck --noautomount ...". To mount without a terminal,ecryptfs-insert-wrapped-passphrase-into-keyring ~/.ecryptfs/wrapped-passphrase -with the login password on standard input, then/sbin/mount.ecryptfs_private;/sbin/umount.ecryptfs_private.