EQTY LabDocs

Run a Guest Notary

Boot a QEMU VM on a hardware-rooted vTPM, install the Linux notary inside it, and verify that a manifest from the guest chains back to the host's hardware.

View as Markdown

This tutorial gives a Linux VM a TPM rooted in the host’s TPM or Secure Enclave, runs the notary inside the VM on that TPM, and checks that a credential from the guest chains to the host. It works the same on a Linux workstation with KVM and a hardware TPM, and on an Apple silicon Mac with HVF and the Secure Enclave. You need:

  • A host notary with the swtpm-notary fork installed, so new vTPMs are hardware-rooted. Check with eqty-notaryctl vtpm show: backing=identity, hardwareEps=true.
  • QEMU. On a Mac: brew install qemu xorriso.
  • The notary’s Linux .deb for the guest’s architecture, from the vcomp-notary-desktop release: _amd64 for a Linux x86_64 host, _arm64 for a Mac.

What a guest notary adds

A guest notary on a vTPM treats it as its hardware TPM. At startup it reads the EK certificate and chain from NV, has the IAK certify its own AK and issue the AK’s certificate, and carries all of it in its VCompTpmV1 identity; see Credentials. Containers in the VM then sign through the guest notary and their manifests chain, through the vTPM, to the host’s hardware.

1. Create the vTPM

For your own user, so that QEMU runs without root:

sh
sudo eqty-notaryctl vtpm create --id guest1 --client-uid "$(id -u)" --client-gid "$(id -g)"
eqty-notaryctl vtpm show guest1

QEMU needs the control socket: /var/run/eqty-notary/vtpm/guest1.sock.ctrl.

2. Prepare the VM

An Ubuntu cloud image, with cloud-init installing Docker and tpm2-tools and authorizing your SSH key on first boot. The VM boots with ima_policy=tcb later, in step 4.

sh
mkdir -p ~/vtpm-vm && cd ~/vtpm-vm
curl -LO https://cloud-images.ubuntu.com/releases/26.04/release/ubuntu-26.04-server-cloudimg-amd64.img
qemu-img create -f qcow2 -F qcow2 -b ubuntu-26.04-server-cloudimg-amd64.img disk.qcow2 20G
cp /usr/share/OVMF/OVMF_VARS_4M.fd vars.fd
sh
mkdir -p ~/vtpm-vm && cd ~/vtpm-vm
curl -LO https://cloud-images.ubuntu.com/releases/26.04/release/ubuntu-26.04-server-cloudimg-arm64.img
qemu-img create -f qcow2 -F qcow2 -b ubuntu-26.04-server-cloudimg-arm64.img disk.qcow2 20G
cp "$(brew --prefix qemu)/share/qemu/edk2-arm-vars.fd" vars.fd
sh
[ -f ~/.ssh/id_ed25519 ] || ssh-keygen -t ed25519 -N '' -f ~/.ssh/id_ed25519
mkdir -p seed
cat > seed/meta-data <<EOF2
instance-id: vtpm-vm
local-hostname: vtpm-vm
EOF2
cat > seed/user-data <<EOF2
#cloud-config
users:
  - name: ubuntu
    sudo: ALL=(ALL) NOPASSWD:ALL
    groups: [docker, tss]
    shell: /bin/bash
    ssh_authorized_keys: ["$(cat ~/.ssh/id_ed25519.pub)"]
packages: [docker.io, tpm2-tools]
EOF2
xorriso -as mkisofs -quiet -o seed.iso -V cidata -J -r seed

3. Boot with the vTPM

sh
CTRL=/var/run/eqty-notary/vtpm/guest1.sock.ctrl
qemu-system-x86_64 -machine q35,accel=kvm -cpu host -m 4096 -smp 4 \
  -drive if=pflash,format=raw,readonly=on,file=/usr/share/OVMF/OVMF_CODE_4M.fd \
  -drive if=pflash,format=raw,file=vars.fd \
  -drive if=virtio,file=disk.qcow2 \
  -drive if=virtio,format=raw,readonly=on,file=seed.iso \
  -chardev socket,id=chrtpm,path="$CTRL" \
  -tpmdev emulator,id=tpm0,chardev=chrtpm \
  -device tpm-tis,tpmdev=tpm0 \
  -netdev user,id=n0,hostfwd=tcp:127.0.0.1:2222-:22 -device virtio-net-pci,netdev=n0 \
  -display none -serial file:console.log -daemonize -pidfile qemu.pid
sh
CTRL=/var/run/eqty-notary/vtpm/guest1.sock.ctrl
qemu-system-aarch64 -machine virt,accel=hvf -cpu host -m 4096 -smp 4 \
  -drive if=pflash,format=raw,readonly=on,file="$(brew --prefix qemu)/share/qemu/edk2-aarch64-code.fd" \
  -drive if=pflash,format=raw,file=vars.fd \
  -drive if=virtio,file=disk.qcow2 \
  -drive if=virtio,format=raw,readonly=on,file=seed.iso \
  -chardev socket,id=chrtpm,path="$CTRL" \
  -tpmdev emulator,id=tpm0,chardev=chrtpm \
  -device tpm-tis-device,tpmdev=tpm0,ppi=off \
  -netdev user,id=n0,hostfwd=tcp:127.0.0.1:2222-:22 -device virtio-net-pci,netdev=n0 \
  -display none -serial file:console.log -daemonize -pidfile qemu.pid

Keep ppi=off. QEMU 11.1 and later abort under HVF without it, with HV_BAD_ARGUMENT. It turns off only the Physical Presence Interface, the guest’s way to ask the firmware to clear the TPM.

The three TPM lines are what matters: -chardev points at the notary’s swtpm. The first boot takes a minute or two while cloud-init installs packages. Then:

sh
ssh -p 2222 ubuntu@127.0.0.1 'ls -l /dev/tpm0 /dev/tpmrm0; cloud-init status --wait'

4. Turn on IMA in the guest

The guest notary binds its quote to IMA’s measurement of its own binary, so the guest kernel must measure. Because QEMU attaches the TPM at boot, IMA extends PCR 10 in the host-rooted vTPM from the first measurement.

sh
ssh -p 2222 ubuntu@127.0.0.1 '
  echo "GRUB_CMDLINE_LINUX_DEFAULT=\"\$GRUB_CMDLINE_LINUX_DEFAULT ima_policy=tcb\"" | sudo tee /etc/default/grub.d/90-eqty-ima.cfg
  sudo update-grub && sudo reboot'

Powering the VM off stops the vTPM. If you shut the VM down rather than rebooting it, run eqty-notaryctl vtpm start guest1 before booting again.

5. Install the guest notary

Turn the Key Guardian off before installing: the package starts the notary immediately, and with Key Guardian on it fetches a Key Guardian certificate that it then prefers over the vTPM IAK’s, so the chain ends at the Key Guardian instead of at your host.

sh
scp -P 2222 eqty-notary_<version>_<arch>.deb ubuntu@127.0.0.1:
ssh -p 2222 ubuntu@127.0.0.1 '
  sudo mkdir -p /etc/systemd/system/eqty-notary.service.d
  printf "[Service]\nEnvironment=EQTY_KEY_GUARDIAN_URL=\n" | sudo tee /etc/systemd/system/eqty-notary.service.d/no-key-guardian.conf
  sudo apt-get install -y ./eqty-notary_*.deb
  until curl -sf http://127.0.0.1:8066/v1/isReady; do sleep 2; done; echo'

On start the guest notary reads the vTPM’s EK and IAK certificates from NV, creates its own AK and has the IAK certify it, quotes PCR 9 and 10, and issues its VCompTpmV1 identity with all of that as evidence. Readiness takes about 30 seconds.

6. Check the chain

In the guest, the certificates verify with OpenSSL alone: EK to root, and AK to IAK to root.

sh
ssh -p 2222 ubuntu@127.0.0.1 '
  cd /tmp
  sudo tpm2_nvread 0x01c0000a -o ek.der && sudo tpm2_nvread 0x01c90100 -o iak.der && sudo tpm2_nvread 0x01c00100 -o root.der
  for f in ek iak root; do openssl x509 -inform der -in $f.der -out $f.pem; done
  openssl verify -CAfile root.pem ek.pem iak.pem
  openssl x509 -in root.pem -noout -ext subjectAltName'

The root’s subject alternative name is the host notary’s did:key. Compare it with the host:

sh
curl -s http://127.0.0.1:8066/v1/system_public_key | jq -r .did

Then fetch the guest notary’s credential and verify it offline:

sh
ssh -p 2222 ubuntu@127.0.0.1 'curl -s http://127.0.0.1:8066/v1/credential' > guest-identity.json
eqty-notary-verify guest-identity.json

tpmAKCertificate in the guest’s VCompTpmV1 holds the AK certificate issued by the IAK, the IAK certificate and the root; tpmEKCertificate the EK certificate and the root. A verifier gets one X.509 chain from the quoting AK to your host notary, plus the TPM’s own statement, the IAK’s TPM2_Certify, that the AK and IAK share a TPM.

7. Sign from a container in the guest

Containers in the VM reach the guest notary at the well-known address. The EQTY SDK’s simple.py example from eqtylab/container_example signs every statement through it:

sh
ssh -p 2222 ubuntu@127.0.0.1 '
  git clone https://github.com/eqtylab/container_example && cd container_example/simple_py
  docker build -t simple-py . && docker run --rm -e ENDPOINT=http://100.100.100.200:8066 -v $PWD/out:/out simple-py'

The resulting manifest’s statements are registeredBy the container’s process key, whose VCompContainerV1 is registered by the guest notary, whose VCompTpmV1 carries the chain to the host. The chain in full: workload statements, process key, guest notary, AK, vTPM IAK, host notary.

Day to day

TaskCommand
Start the vTPM before a booteqty-notaryctl vtpm start guest1
Several VMsOne vTPM per VM. All containers in one VM share its EK and IAK.
Remove itsudo eqty-notaryctl vtpm delete guest1. Irreversible: the keys are destroyed.