1.4 KiB
1.4 KiB
Linux+ 3.5.1: Encrypting data at rest
A LUKS volume on a spare disk, a key file for it, and a file encrypted with GnuPG.
Before you start
The lab adds a spare disk, /dev/loop40 (256 MiB, empty), for you to
encrypt. It's an image file under /var/lib/le-lab/disks/, attached again
at every boot. Nothing opens the LUKS volume at boot: after a reboot, open
it with the key file and mount it again before you check.
Tasks
- Install
cryptsetupif it's missing. Format/dev/loop40with LUKS (choose a passphrase), open it aslab, make an ext4 filesystem on it, mount it on/mnt/lab, and writehiddento/mnt/lab/file.txt. - Look at the LUKS header. Make a 64-byte random key file,
/root/lab.key, with mode 400, and add it to the volume. Then lock the volume (unmount and close it), see that the disk can't be mounted directly, and open it again with the key file and mount it on/mnt/lab. - In your home directory, encrypt a file
n.txtwith GnuPG, with a passphrase (symmetric encryption), ton.txt.gpg, and decrypt it again.
Hints
cryptsetup luksFormat,cryptsetup open,mkfs.ext4,lsblk.cryptsetup luksDump,dd if=/dev/urandom bs=64 count=1,cryptsetup luksAddKey DEVICE KEYFILE;cryptsetup close,blkid,cryptsetup open --key-file.gpg --pinentry-mode loopback -c,gpg --pinentry-mode loopback -d.