If you have a LUKS container and want it to unlock, without reading the scripts, run sudo ./install.sh
. This will:
Current installations of Ubuntu come with System D that are built to support TPM2 already. If you're trying to get older Ubuntu to work with a TPM, you'll need to modify the scripts to build SystemD with TPM2 support enabled. Code is available in the install script, it will install Docker on your host system and then do all the work inside docker, so there is minimal impact. The CWD will get some extra packages added to it, plus some extra directories with source files inside, but you can ignore all of that - once the script has completed successfully this entire directory can be removed.
These files build on the 'cryptroot' module in initramfs-tools/cryptsetup to allow the bash /etc/crypttab
file to support the 'tpm-device=xxx' option and pass it through to the systemd-crypsetup application to allow automatically decrypting a device using LUKS and a TPM.
To compile Systemd with TPM2 support, the script build_systemd_with_tpm2_support.sh
can be used to either build inside a fresh ubuntu:22.04 image, or on the host.
This will create the deb files for system in the current working directory.
To build inside a fresh docker image: ./build_systemd_with_tpm2_support.sh
Or, to build on this host directly: ./build_systemd_with_tpm2_support.sh on_this_host
I've been unable to establish who publishes the files I've patched and how they are licensed, so I've only included the patch here so I do not infringe anyone's copyright or break licensing.
This is a rough and ready summary of the process to get a system running with an encrypted root. It isn't as detailed as I'd like and there are more ways to get this to work (Work in Progress!). A lot of this has been developed from the excellent articles in Arch Linux, so if there are steps missing you may need to read around the issues, or ask in the 'Issues' and someone (possibly me) will answer when they can.
Potentially useful pages for more context:
NB: big thanks to the authors of these articles - they helped me get most of the way here!
(using an Ubuntu Desktop live environment some of 1, 2 & 3 probably needs to be done before starting the installer)
sudo ./install.sh
systemd-cryptenroll
NB: This doesn't protect against a modified initrd as yet. That's another stage of configuring secure boot and creating an (optionally signed) Unified Kernel Image (or enabling key verification with GRUB2 or something along those lines!) But this is a good step on the way! NB2: Apparently the Linux kernel now measures it's own initrd, so if the systemd-cryptenroll is called with the correct registers, then that may be covered off (see issue 2) linked below.
Check this issue for more details about below and any discussion of other attacks to be aware of - or to share details of other attacks that users should be aware of!
You may want to create a unified kernel - this protects against a modified initrd attack. See: this repo]
SecureBoot uses cryptographically signed bootloaders to ensure that the BIOS will not even load an attacker's OS on your hardware. Useful if you are concerned about an attacker repurposing your kit. There's nothing here for now, so read around the topic and feel free to create an issue with comments or even a Pull Request with a link to your repository here.