Skip to content

Instantly share code, notes, and snippets.

@seysn
Created February 21, 2022 16:09
Show Gist options
  • Save seysn/10cbd80f3e448df256df690a56739f51 to your computer and use it in GitHub Desktop.
Save seysn/10cbd80f3e448df256df690a56739f51 to your computer and use it in GitHub Desktop.
#!/bin/sh
if [ -f ".tpm2-getkey.tmp" ]; then
# tmp file exists, meaning we tried the TPM this boot, but it didn’t work for the drive and this must be the second
# or later pass for the drive. Either the TPM is failed/missing, or has the wrong key stored in it.
/lib/cryptsetup/askpass "Automatic disk unlock via TPM failed for () Enter passphrase: "
exit
fi
# No tmp, so it is the first time trying the script. Create a tmp file and try the TPM
touch .tpm2-getkey.tmp
tpm2_nvread 0x1500016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment