我正在尝试使用tpm2-tools和Tevora Secure boot tpm2的指令来创建基于TPM的解锁脚本。我已经设置了密钥,并用cryptsetup luksAddKey secret.bin
加载了该密钥,然后使用tpm2_unlock -c 0x81000000 --auth pci:sha1:0,2,3,7
对其进行了测试,并返回secret.bin的值。为了采取其他措施,为确保其正常运行,我将secret.bin加载到“ / etc / crypttab”中,运行# update-initramfs -u -k all
,然后重新启动。重新启动后,系统已解锁。
我将以下代码复制到“ / etc / initramfs-tools / hooks / tpm2”中
#!/bin/sh -e
if [ "$1" = "prereqs" ]; then exit 0; fi
. /usr/share/initramfs-tools/hook-functions
copy_exec /usr/local/bin/tpm2_unseal
copy_exec /usr/local/lib/libtss2-tcti-device.so
我将我的etc / crypttab从cryptname UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx none luks
附加到cryptname UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx none luks,keyscript=/usr/local/bin/passphrase-from-tpm
我重写了以下脚本,因为tpm2-tools命令已过时,在新命令中进行了编辑,并将其存储在/ usr / local / bin / passphrase-from-tpm中。
#!/bin/sh
set -e
echo "Unlocking via TPM" >&2
export TPM2TOOLS_TCTI="device:/dev/tpm0"
/usr/local/bin/tpm2_unseal -c 0x81000000 --auth pcr:sha1:0,2,3,7
if [ $? -eq 0 ]; then
exit
fi
/lib/cryptsetup/askpass "Unlocking the disk fallback $CRYPTTAB_SOURCE ($CRYPTTAB_NAME)\nEnter passphrase: "
我运行了# update-initramfs -u -k all
,然后重新启动。重新启动时,出现以下错误:/lib/cryptsetup/scripts/passphrase-from-tpm: line 5: /usr/local/bin/tpm2_unseal: not found
我已经尝试过多次尝试从tpm修改密码,包括:
在我弄清楚如何使用以下方法创建备份Linux引导之前:
objcopy \
--add-section .osrel=/etc/os-release --change-section-vma .osrel=0x20000 \
--add-section .cmdline=cmdline.txt --change-section-vma .cmdline=0x30000 \
--add-section .linux="/boot/vmlinuz" --change-section-vma .linux=0x40000 \
--add-section .initrd="/boot/initrd.img" --change-section-vma .initrd=0x3000000 \
/usr/lib/systemd/boot/efi/linuxx64.efi.stub /boot/EFI/BOOT/BOOT_RECX64.EFI
由于该错误,我将完全被锁定在系统之外,必须重新安装Ubuntu约40次。我受了很多苦,想辞职,但我太固执了,不能高举旗帜。
只需将tpm2_unseal复制到/ usr / local / bin /