OK thanks. “You cannot set it up to require both.” I got open AI to write the step by step to actually do just that. I am going to practice once on a usb external drive.
OK, I am actually trying to find only that section to post. I will have to clarify with AI.
I am thinking using a 63 character PIN with required yubikey would serve as a 2FA and be good enough.
So propmt to insert Yubikey, Prompt for 63 character PIN, prompt for touch.
“FIDO2 PINs can be up to 63 alphanumeric characters (in other words, letters and numbers). For YubiKeys from the 5 FIPS Series,”
OK here is the section that requires BOT not either or…
FROM FREE -AI
You can configure Linux (specifically using systemd-cryptsetup or cryptsetup) to require both a LUKS2 passphrase AND a YubiKey (via FIDO2/U2F or PAM) to unlock the disk. This is known as “two-factor authentication” for disk encryption.
How it works
- LUKS2 Header: The LUKS2 header supports multiple keyslots. You can assign the passphrase to one keyslot and the YubiKey credential to another.
- Key Requirements: By default, LUKS2 only requires one valid keyslot to unlock. To require both, you need an additional layer that enforces the “AND” logic.
- Enforcement: This is typically done via:
systemd-cryptsetup with luks2 and specific options.
PAM (Pluggable Authentication Modules) in combination with cryptsetup.
*Custom scripts or udev rules that check for both conditions before proceeding.
Recommended Approach: systemd-cryptsetup + PAM
The most robust and standard way on modern Linux distributions (like Fedora, Ubuntu, Debian) is to use systemd-cryptsetup along with PAM to enforce two-factor authentication.
Steps:
- Add YubiKey to LUKS2 (optional but recommended):*
sudo cryptsetup luksAddKey /dev/sdX /dev/your-yubikey-device
Note: You can also use FIDO2/U2F directly with cryptsetup luksAddToken.*
- Configure PAM for Two-Factor:
Edit /etc/pam.d/system-auth or /etc/pam.d/login to require both password and YubiKey. Example:*
auth required pam_unix.so
auth required pam_u2f.so cue
This ensures that even if someone steals your password, they can’t unlock the system without the YubiKey.
- Use systemd-cryptsetup with
luks2:
In /etc/crypttab, ensure your encrypted device uses luks2 and that the keyfile/passphrase is required. The PAM configuration above will enforce the second factor during the login process, which triggers the decryption.
Alternative: FIDO2/U2F Directly with cryptsetup
Newer versions of cryptsetup support FIDO2/U2F tokens directly as LUKS2 tokens. You can add a FIDO2 token and then configure the system to require both the passphrase and the token.
*
sudo cryptsetup luksAddToken /dev/sdX --token-id 0 --token-type fido2-with-pin
…
By also adding a strong PIN on your Yubikey they cannot use it wihout the PIN. So it becomes 3FA. A bit of overkill I guess. The yubikey PIN has a 8 guess brick mode. After 8 the key locks forever. Which totally screws over brute forcing.
AI said the entropy of a long and strong passphrase was the most important.