-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Why LUKS instead of .tar.gpg? #446
Comments
Indeed, one could symmetrically encrypt the private key and backup contents with GPG (though I would still recommend using a different passphrase from identity). The resulting archive would be more portable and convenient to use. However, portability and convenience of accessing backups is not a goal of this guide and, in a way, LUKS limits portability to encourage use of a secure-ish operating environment. I also suppose the argument could be made that using different encryption programs to secure key material is "better", but in practice this is likely not relevant. In other words, in terms of at-rest encryption protection, LUKS and GPG are likely equivalent. I'm curious what you mean by LUKS being error-prone. If it truly is a hassle for readers, we could simplify the instructions and move LUKS to Optional Hardening. What do you think? Is there anything else to consider? |
Maybe it's just me, but I never interact with LUKS directly, which means I don't know what all those commands mean, and there's a lot to learn already about gpg and yubikey-manager. Also, by error-prone I mean manipulation of partitions in |
Another option may be to use LUKS with a loop device, the latter of which is a file used as a block device, not to be confused with loop-AES, the latter of which seems to be an alternative to LUKs. Using a loop device has similar advantages to the current LUKs steps but has two, IMHO, significant advantages:
Disadvantages:
I think this approach can also be used with the OpenBSD equivalent, virtual node devices, but I have not tried it. Linux StepsThe steps have been tested on Debian Live 12.8.0:
The loop device specific steps are based on the cryptsetup FAQ:
I have marked the new/modified steps with (changed) Choose a name for the encrypted loop device file: export LUKS_GPG_BACKUP_FILE="gpg_backup_luks" (changed) Create a small (at least 20 Mb is recommended to account for the LUKS header size) loop device file for storing secret materials: head -c 20M /dev/zero > "$LUKS_GPG_BACKUP_FILE" (changed) Associate sudo losetup -f -L "$LUKS_GPG_BACKUP_FILE" (changed) Ensure losetup is on non-sudo user PATH, which is needed on some OS's such as Debian Live 12.8.0: export PATH="/usr/sbin:$PATH" (changed) Determine what loop device was used: export LUKS_GPG_BACKUP_LOOP_DEVICE=$(losetup -j "$LUKS_GPG_BACKUP_FILE" |cut -d: -f1) Generate another unique Passphrase (ideally different from the one used for the Certify key) to protect the encrypted volume: export LUKS_PASS=$(LC_ALL=C tr -dc 'A-Z1-9' < /dev/urandom | \
tr -d "1IOS5U" | fold -w 30 | sed "-es/./ /"{1..26..5} | \
cut -c2- | tr " " "-" | head -1) ; printf "\n$LUKS_PASS\n\n" This passphrase will also be used infrequently to access the Certify key and should be very strong. Write the passphrase down or memorize it. (changed) Format the loop device: echo $LUKS_PASS | sudo cryptsetup -q luksFormat "$LUKS_GPG_BACKUP_LOOP_DEVICE" (changed) Mount the loop device echo $LUKS_PASS | sudo cryptsetup -q luksOpen "$LUKS_GPG_BACKUP_LOOP_DEVICE" gnupg-secrets Create an ext2 filesystem: sudo mkfs.ext2 /dev/mapper/gnupg-secrets -L gnupg-$(date +%F) Mount the filesystem and copy the temporary GnuPG working directory with key materials: sudo mkdir /mnt/encrypted-storage
sudo mount /dev/mapper/gnupg-secrets /mnt/encrypted-storage
sudo cp -av $GNUPGHOME /mnt/encrypted-storage/ (changed) An example to better visualize the relationship between the underlying file
(changed) Unmount and close the encrypted volume and detach the loop device: sudo umount /mnt/encrypted-storage
sudo cryptsetup luksClose luksfile
sudo losetup -d "$LUKS_GPG_BACKUP_LOOP_DEVICE" (changed) Copy SigningI'd also suggest with this approach to also sign the backing file. This would be especially useful if backing up the file to remote storage. |
Any particular reason? LUKS seems error-prone compared to a single command of encrypting a folder.
Thank you for the guide, by the way.
The text was updated successfully, but these errors were encountered: