clevis
Table of Content
General
clevis
is a framework for automated decryption policy. It allows you to define a policy at encryption time that must be satisfied for the data to decrypt. Once this policy is met, the data is decrypted.
Installation
$ apt install clevis
There are some integrations for clevis which can be right handy, for example:
- clevis-dracut
- clevis-initramfs
- clevis-luks
- clevis-systemd
- clevis-tpm2
- clevis-udisk2
Setup
Debian
performed beneath Debian 13/Trixie with UEFI and initramfs
So first of all, we have to install clevis
as shown above and we also want to install clevis-initramfs
and clevis-luks
for our use case.
To add tang
/clevis
as a new encyption slot in your luks
partition, you can use this command:
$ clevis luks bind -d /dev/<diskpartition> tang '{"url": "http://<your tang server>:<tang server port>"}'
Enter existing LUKS password:
The advertisement contains the following signing keys:
63rlX6JxefzIaf15K8eh1oCc_5u5f8Cd0fgKnTd6Ujc
Do you wish to trust these keys? [ynYN]
This will ask your for your encyption password and after you have enter that one (successfully), you will see a new keyslot used, which can be done with:
$ cryptsetup luksDump /dev/<diskpartition>
Next is, that we confirugre initramfs and added the needed binaries to it.
First lets create the file /etc/initramfs-tools/scripts/local-top/run_net
which will contain:
#!/bin/sh
. /scripts/functions
configure_networking
This will ensure that we will reload the network configuration while running the initramfs.
Next, we add a hook /usr/share/initramfs-tools/hooks/curl
for add curl binary and certificates to the initramfs:
#!/bin/sh -e
PREREQS=""
case $1 in
prereqs) echo "${PREREQS}"; exit 0;;
esac
. /usr/share/initramfs-tools/hook-functions
#copy curl binary
copy_exec /usr/bin/curl /bin
#fix DNS lib (needed for Debian 11)
cp -a /usr/lib/x86_64-linux-gnu/libnss_dns* "${DESTDIR}/usr/lib/x86_64-linux-gnu/"
#DNS resolver
echo "nameserver <YOUR DNS SERVER IP>\n" > "${DESTDIR}/etc/resolv.conf"
#copy ca-certs for curl
mkdir -p "${DESTDIR}/usr/share"
cp -ar /usr/share/ca-certificates "${DESTDIR}/usr/share/"
cp -ar /etc/ssl "${DESTDIR}/etc/"
To load the correct driver/module into initramfs for your network card you need to add it to /etc/initramfs-tools/modules
like it is described in the file itself.
After you are done with that, configure /etc/initramfs-tools/initramfs.conf
by adding these two lines:
Device=<contains your network interface name>
IP=<your client static ip>::<your network gateway>:<your network mask>::<your network interface name, same as in Device>
if you use DHCP
and you need to use this IP
value instead:
IP=:::::<your network interface name, same as in Device>:dhcp
As final step, you need to update your initramfs by running:
$ update-initramfs -u -k "all"
If you want to check if everything got stored on the initramfs use the command lsinitrd
to do so:
$ lsinitrd /boot/initramfs-<version>.img | grep 'what you are looking for'
Tang did a rekey lets rekey clevis
If you are using a tang
server to automatically unlock your disk for example, it might happen that a rekey was performed.
To be able to deal with that, check which slot is used for tang
in the luks parition and perform a clevis luks report
like this:
$ clevis luks list -d /dev/sda2
1: tang '{"url":"http://localhost:8080"}'
$ clevis luks report -d /dev/sda2 -s 1
...
Report detected that some keys were rotated.
Do you want to regenerate luks metadata with "clevis luks regen -d /dev/sda2 -s 1"? [ynYN]
If you hit there [y|Y]
it will enable the new key created by the tang
key rotation.
What you can do as well, is to execute this one:
$ clevis luks regen -d /dev/sda2 -s 1