Trusted Boot Installations
Warning
This section is still a work in progress and only available in Kairos v3.x releases and alphas.“Trusted Boot” is a combination of technologies that allows us to guarantee that a system was not tampered with, and the user-data is protected by cold attacks, it is composed by FDE, Secure Boot and Measured Boot.
If you want to learn more on what Trusted Boot is and how it works, see the Trusted Boot Architecture page. This page describes how to enable Trusted Boot support in Kairos.
Kairos supports Trusted boot by generating specific installable medium. This feature is optional and works alongside how Kairos works.
Requirements
The Hardware that will run Kairos needs to have the following requirements:
- Secure boot available in the system
- The Hardware should have a TPM chip or fTPM enabled
- The Hardware should be capable of booting large EFI files (>32MB)
- Base image of the OS needs to have at least systemd 252 or newer ( for example ubuntu >=23.10 or fedora >=38 )
To build the installable medium you need the following installed in the system you use to build the installable medium:
- Docker
- Git
- A Linux machine with KVM (for testing the images locally)
Usage
In order to boot into UKI mode, you need to build a special ISO file with the UKI files. To build this medium you have to generate a set of keypairs first: one for the Secure boot and one for the PCR policies required to encrypt the user-data.
Any change, or upgrade of the node to a new version of the OS requires those assets to be regenerated with these keypairs, including the installer ISO, and the EFI files used for upgrading. The keys are used to sign and verify the EFI files, and the PCR policies are used to encrypt and decrypt the user-data, and thus are required to be the same for the whole lifecycle of the node.
The steps below will guide you into generating the installable assets, and how to re-generate the assets to upgrade the node to a new version of the OS.
Build the container image used to generate keys and installable medium
Key generation
To generate the Secure boot certificates and keys run the following commands:
Warning
Substitute$MY_ORG
for your own string, this can be anything but it help identifying the Keys. The keys duration can specified with --expiration-in-days
. It is not possible to create keys that do not expire, but it is possible to specify an extremely large value (e.g. 200 years, etc.)
Warning
It is very important to preserve the keys generated in this process in a safe place. Loosing the keys will prevent you to generate new images that can be used for upgrades.Building installable medium
To build the installable medium you need to run the following commands:
Config files
Included in the artifact will be a configuration file. On the installation/upgrade media, it is called norole.conf
but once it has been installed it will be named active.conf
, passive.conf
or recovery.conf
which represents the configuration for the “cos”, “fallback” and “recovery” images respectively.
This configuration file includes the “title” of the artifact in the boot menu and the location of the “efi” file to boot. Here’s an example:
# cat /efi/loader/entries/active.conf
efi /EFI/kairos/active.efi
title Kairos
Branding
You can overwrite the default “Kairos” title if you pass the --boot-branding
flag to enki.
Your config file should look now like this:
# cat /efi/loader/entries/active.conf
efi /EFI/kairos/active.efi
title My Awesome OS
Warning
Remember when you build upgrade mediums, to also add your branding, otherwise the new active image will be named differently than your fallback and recovery ones.Version and cmdline in the config files
In addition to having the “title” and “efi” attributes, you can include in the config files the OS “version” and “cmdline”. To do so, pass --include-version-in-config
or --include-cmdline-in-config
flags to enki.
Info
The cmdline, will only show what is different between the default cmdline and the currently used cmdline. If you pass--include-cmdline-in-config
to a default installation, the attribute cmdline will be empty.
cmdline awesome=true
title Awesome OS
efi /EFI/kairos/active.efi
version v3.0.0
Installation
The installation process is performed as usual and the Installation instructions can be followed, however the difference is that user-data will be automatically encrypted (both the OEM and the persistent partition) by using the TPM chip and the Trusted Boot mechanism.
Enroll the keys in Secure Boot
If your machine is in UEFI setup mode Secure Boot keys will be automatically enrolled. To enter UEFI Setup mode you need to clear the Secure Boot keys (PKs) from the BIOS/UEFI.
If UEFI setup mode is not available, you need to enroll the keys manually in the BIOS/UEFI.
This process can vary depending on the vendor, but in general you need to enter the BIOS/UEFI setup during early boot and import the keys, for an example outline you can check the steps for HPE Hardware.
A video of the process of importing keys in QEMU is available here.
Upgrades
See the Trusted Boot Upgrade page.
Testing the images locally
To test the ISO file locally QEMU can be used. In order to test Secure Boot components you need an ed2k firmware with secureboot in QEMU. If you don’t have QEMU locally and/or you don’t have the correct dependencies you can follow the steps below that build a container image with QEMU and the needed dependencies and use that container to run the ISO file in a VM with Docker.
- Build the container image with the QEMU/Secure Boot dependencies (note to replace disk, VM size and ISO file name):
- Start a TPM socket:
Note: you need to keep the TPM container up and running for the VM to boot. Run the commands below in another terminal window.
- Run the container image with the ISO file (replace the iso file name with yours):
Note: To stop the QEMU container you can use Ctrl-a x
or Ctrl-a c
to enter the QEMU console and then quit
to exit.
- After installation, you can run the container image by booting only with the disk
Note: you need to keep the TPM container up and running for the VM to boot.
Data Encryption
The user-data will be automatically encrypted during installation, along with the OEM and the persistent partition by using the TPM chip and the Trusted Boot mechanism.
Additional partitions
Additional partitions can be encrypted and specified as part of the cloud-config used during the installation process, for example:
A full example can be:
Notes
Install additional files from the Installer ISO to the encrypted portions
The ISO installer images can be used to install additional content in the encrypted portion of the disk.
The osbuilder image can overlay additional files into the iso. For example specify --overlay-iso /additional/path
to have added the files in the folder inside the ISO. The content can be accessed during installation in /run/initramfs/live
.
For example, to install content of the ISO inside the OEM partition, and to restore those after a reset we can use the following cloud config:
Mount partitions after install
/oem
and /usr/local
can be mounted after installation to prepare content before first-boot.
To mount /oem
and /usr/local
after install you can also manually call kcrypt unlock-all
. However this isn’t supported yet.
Feedback
Was this page helpful?
Awesome! Glad to hear it! Please tell us how we can improve.
Oh snap! Sorry to hear that. Please tell us how we can improve.