Score:0

LUKS + TPM2 + auto unlock at boot (systemd-cryptenroll)

cm flag

Please, help me to finish setup LUKS + TPM2 + auto unlock at boot.

I have installed clean Ubuntu 22.04.2 I have encrypted partition in GUI while installing OS. I have installed all updates.

Ubuntu 22.04.2 LTS
5.19.0-43-generic
systemd 249 (249.11-0ubuntu3.9)

I am trying to use this manual: https://wiki.archlinux.org/title/Trusted_Platform_Module#systemd-cryptenroll

I have installed:

tpm2-tools
dracut-core_059-3_amd64.deb
dracut_059-3_all.deb

Next:

sudo dracut --add tpm2-tss
sudo systemd-cryptenroll --tpm2-device=auto --tpm2-pcrs=0+7 /dev/nvme0n1p3

I have added in /etc/crypttab:

nvme0n1p3_crypt UUID=1fce6364-485c-4524-9c73-7bd4dac5bd32 none luks,discard

System still asking for a passphrase while booting.

I am do not understand what I need to do exactly to auto-unlock LUKS via TPM on boot.

Score:2
iq flag

This is what I'm using to allow LUKS decryption using TPM2 in the same Ubuntu 22. Not using systemd-cryptenroll, but clevis. The only 'downside' is that it shows the password prompt at boot, but disappears after getting the key from tpm.

    #!/bin/bash
    
    #install needed packages
    apt-get -y install clevis clevis-tpm2 clevis-luks clevis-initramfs initramfs-tools tss2
    
    #proceed
    echo -n Enter LUKS password:
    read -s LUKSKEY
    echo ""
    
    clevis luks bind -d /dev/nvme0n1p3 tpm2 '{"pcr_bank":"sha256"}' <<< "$LUKSKEY"
    
    update-initramfs -u -k all
    
    #check
    clevis luks list -d /dev/nvme0n1p3
    
    #delete example; -s is one of the slots reported by the previous command
    #clevis luks unbind -d /dev/nvme0n1p3 -s 1 tpm2

No need to modify anything else(not even crypttab file).

Vasiliy avatar
cm flag
Thank you! I will try it. I have tried to use "build-in" (systems) to unlock LUKS.
blisstdev avatar
kr flag
Thank God for you! This information was so convoluted to find, and this was so succinct and easy, and worked!
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.