Last active
November 25, 2023 21:14
-
-
Save mallendeo/28166698ee716b93cb4b372e406f78bb to your computer and use it in GitHub Desktop.
Unlock LUKS using attached USB dongle at boot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /bin/luksunlockusb | |
# | |
# Add to /etc/initramfs-tools/modules | |
# usb-storage | |
# | |
# Add key: | |
# sudo cryptsetup luksAddKey /dev/sdb /home/user/.crypt_file | |
# | |
# Edit /etc/crypttab | |
# nvr_luks UUID=xxxxxxxxxxxx /home/user/.crypt_file luks | |
# | |
# sudo update-initramfs -u | |
#!/bin/sh | |
set -e | |
if [ ! -e /mnt ]; then | |
mkdir -p /mnt | |
sleep 3 | |
fi | |
for usbpartition in /dev/disk/by-id/usb-*-part1; do | |
usbdevice=$(readlink -f $usbpartition) | |
if mount -t ext4 $usbdevice /mnt 2>/dev/null; then | |
if [ -e /mnt/$CRYPTTAB_KEY.lek ]; then | |
cat /mnt/$CRYPTTAB_KEY.lek | |
umount $usbdevice | |
exit | |
fi | |
umount $usbdevice | |
fi | |
done | |
/lib/cryptsetup/askpass "Insert USB key and press ENTER: " |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment