Skip to content

Commit 0c280f3

Browse files
author
Roy Kaufman
committed
clevis-pin-trustee for attestation.
Also, use the shared Containerfile for the custom image. Signed-off-by: Roy Kaufman <[email protected]>
1 parent de7bbfc commit 0c280f3

File tree

19 files changed

+94
-361
lines changed

19 files changed

+94
-361
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ Build the Fedora CoreOS or Centos Stream CoreOS image with the custom initrd:
2222
```bash
2323
cd coreos
2424
# Centos Stream CoreOS image
25-
just os=scos build oci-archive osbuild-qemu
25+
just os=scos build oci-archive osbuild
2626
# Fedora CoreOS image
27-
just build oci-archive osbuild-qemu
27+
just build oci-archive osbuild
2828
```
2929
3030
In this example, we use 2 VMs, the first for running the trustee server while the second VM has been attested and its

coreos/Containerfile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
ARG BASE
2-
FROM quay.io/afrosi_rh/kbs-client-image:latest as kbc
3-
FROM quay.io/confidential-clusters/clevis-pin-trustee as clevis
2+
3+
ARG KBS_CLIENT_IMAGE=quay.io/afrosi_rh/kbs-client-image:latest
4+
ARG CLEVIS_PIN_TRUSTEE_IMAGE
5+
6+
FROM $KBS_CLIENT_IMAGE as kbc
7+
FROM $CLEVIS_PIN_TRUSTEE_IMAGE as clevis
48
FROM quay.io/confidential-clusters/ignition:clevis-pin-trustee as ignition
59
FROM $BASE
610

coreos/justfile

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,35 @@ image := if os == "scos" { scos_img } else { fcos_img }
1717
os_name := if os == "scos" { scos_os } else { fcos_os }
1818
label := if os == "scos" { scos_label } else { fcos_label }
1919
archive := os + ".ociarchive"
20+
platform := "qemu"
21+
kbc_image := "quay.io/afrosi_rh/kbs-client-image:latest"
22+
clevis_pin_trustee_image := "quay.io/confidential-clusters/clevis-pin-trustee"
2023

2124
build:
22-
sudo podman build --no-cache --build-arg BASE={{base}} --build-arg COM_COREOS_OSNAME={{label}} -t {{image}} -f Containerfile .
25+
sudo podman build --no-cache --build-arg BASE={{base}} --build-arg COM_COREOS_OSNAME={{label}} --build-arg KBS_CLIENT_IMAGE={{kbc_image}} --build-arg CLEVIS_PIN_TRUSTEE_IMAGE={{clevis_pin_trustee_image}} -t {{image}} -f Containerfile .
2326

2427
oci-archive:
2528
sudo skopeo copy containers-storage:{{image}} oci-archive:{{archive}}
2629

27-
osbuild-qemu:
30+
osbuild:
2831
#!/bin/bash
2932
set -xeuo pipefail
3033

34+
SELINUX_STATUS=$(getenforce)
35+
36+
if [ "$SELINUX_STATUS" = "Enforcing" ]; then
37+
sudo setenforce 0
38+
fi
39+
3140
TMPDIR=$(mktemp -d)
3241
git clone --depth 1 https://github.com/coreos/custom-coreos-disk-images ${TMPDIR}
3342

34-
sudo -E ${TMPDIR}/custom-coreos-disk-images.sh --platform qemu \
43+
sudo -E ${TMPDIR}/custom-coreos-disk-images.sh --platform {{platform}} \
3544
--ociarchive {{archive}} \
3645
--osname {{os_name}}
3746
rm -rf "$TMPDIR"
38-
sudo chown $USER:$USER {{os}}-qemu.x86_64.qcow2
47+
sudo chown $USER:$USER {{os}}-{{platform}}.x86_64.*
48+
49+
if [ "$SELINUX_STATUS" = "Enforcing" ]; then
50+
sudo setenforce 1
51+
fi

scripts/populate-trustee-kbs.sh

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,22 @@
33
set -euo pipefail
44
# set -x
55

6-
if [[ "${#}" -ne 1 ]]; then
6+
if [[ "${#}" > 3 ]]; then
77
echo "Usage: $0 <path-to-ssh-public-key>"
8+
echo "Optional: $0 <path-to-ssh-public-key> <SERVER_IP> <HOSTNAME>"
89
exit 1
910
fi
1011

1112
KEY=$1
1213
TRUSTEE_PORT=8080
13-
14+
IP=$2
15+
if [[ ${IP} == "" ]]; then
1416
# Setup reference values, policies and secrets
1517
until IP="$(./scripts/get-ip.sh trustee)" && [ -n "$IP" ] && curl "http://${IP}:${TRUSTEE_PORT}" >/dev/null 2>&1; do
1618
echo "Waiting for KBS to be available..."
1719
sleep 1
1820
done
21+
fi
1922
until ssh core@$IP \
2023
-i "${KEY%.*}" \
2124
-o StrictHostKeyChecking=no \
@@ -29,18 +32,22 @@ done
2932
BUTANE=pin-trustee.bu
3033
IGNITION="${BUTANE%.bu}.ign"
3134

32-
sed "s/<IP>/$IP/" configs/remote-ign/${BUTANE} > tmp/${BUTANE}
35+
HOSTNAME=$3
36+
if [[ ${HOSTNAME} == "" ]]; then
37+
HOSTNAME=${IP}
38+
fi
39+
sed "s/<IP>/$HOSTNAME/" configs/remote-ign/${BUTANE} > ${BUTANE}
3340

3441
podman run --interactive --rm --security-opt label=disable \
35-
--volume "$(pwd)/tmp:/pwd" \
42+
--volume "$(pwd):/pwd" \
3643
--workdir /pwd \
3744
quay.io/confidential-clusters/butane:clevis-pin-trustee \
3845
--pretty --strict /pwd/$BUTANE --output "/pwd/$IGNITION"
3946

4047
scp -i "${KEY%.*}" \
4148
-o StrictHostKeyChecking=no \
4249
-o UserKnownHostsFile=/dev/null \
43-
tmp/${IGNITION} core@$IP:
50+
/${IGNITION} core@$IP:
4451

4552
ssh core@$IP \
4653
-i "${KEY%.*}" \

trustee-on-GCP/README.md

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,48 +5,52 @@ This guide provides step-by-step instructions for setting up remote attestation
55

66
## Prerequisites
77

8-
1. Copy the pull secret from [Red Hat OpenShift](https://console.redhat.com/openshift/create/local) to ```~/.config/containers/auth.json``` into auths:quay.io:auth:&lt;pull_secret&gt;
8+
1. Copy the pull secret from [Red Hat OpenShift](https://console.redhat.com/openshift/create/local) to `~/.config/containers/auth.json` under `auths:quay.io:auth:<pull_secret>`
99
2. Install [gcloud](https://cloud.google.com/sdk/docs/install)
10-
3. Configure a subnet on GCP for the server and client by running ```./scripts/network_setup.sh```.
10+
3. Configure a subnet on GCP for the server and client by running `./scripts/network_setup.sh`
1111

1212

13-
## Deploy the trustee server (KBS)
13+
## Deploy the Trustee Server (KBS)
1414

15-
1. Run ```./scripts/deploy-trustee.sh -k <SSH_KEY> -b ./trustee/trustee.bu```. This will start the KBS with the correct configuration (the name of this VM must match the hostname of the server, so it has to match `KBS_HOSTNAME` in `./scripts/rh-coreos/usr/libexec/aa-client`).
16-
2. Access the VM via SSH, then run ```sudo /usr/local/bin/populate_kbs.sh```. This will add the refrence value to Trustee.
15+
1. To deploy the Trustee server, run:
16+
```bash
17+
./trustee-on-GCP/scripts/deploy-trustee.sh -k <SSH_KEY> -b ./trustee-on-GCP/trustee/trustee.bu -i <IMAGE_NAME>
18+
```
19+
2. After the server is up, populate the KBS with the reference value and add the remote ignition file:
20+
```bash
21+
./scripts/populate-trustee-kbs.sh <SSH_KEY> <SERVER_IP> <HOSTNAME>
22+
```
23+
(The default hostname is `kbs`)
1724

18-
## Deploy the client
25+
26+
## Deploy the Client
1927

2028
1. Build a custom RHCOS image by running:
2129
```bash
22-
./scripts/build-rhcos-image.sh <IMAGE_NAME>
30+
cd coreos
31+
just clevis_pin_trustee_image=quay.io/rkaufman/clevis-pin-trustee:latest os=scos base=quay.io/okd/scos-content:4.20.0-okd-scos.6-stream-coreos \
32+
kbc_image=quay.io/rkaufman/kbs-tpm-snp:latest platform=gcp build oci-archive osbuild
2333
```
2434

2535
2. Upload the image to GCP by running:
2636
```bash
27-
./scripts/upload_image_gcp.sh <BUCKET_NAME> <IMAGE_NAME>
37+
./trustee-on-GCP/scripts/upload_image_gcp.sh <BUCKET_NAME> <IMAGE_NAME>
2838
```
2939

3040
3. Deploy the client by running:
3141
```bash
32-
./scripts/deploy-client.sh -k <SSH_KEY> -b ./rh-coreos/luks.bu -n <VM_NAME> -i <IMAGE_NAME>
42+
./trustee-on-GCP/scripts/deploy-client.sh -k <SSH_KEY> -b ./rh-coreos/luks.bu -n <VM_NAME> -i <IMAGE_NAME>
3343
```
34-
This will create the VM, perform attestation and decrypt the disk.
35-
36-
37-
44+
This will create the VM, perform attestation, and decrypt the disk using clevis-pin.
3845

39-
## Info about the kbs and kbs-client
4046

41-
I use this version of [trustee](https://github.com/iroykaufman/trustee/tree/addtpm) and the [guest component](https://github.com/iroykaufman/guest-components/tree/TPM-as-additional-device).
47+
## Information About KBS, KBS-Client, and Clevis-Pin
4248

43-
Trustee includes [pr#851](https://github.com/confidential-containers/trustee/pull/851) with the following changes:
49+
These are modified versions of [trustee](https://github.com/iroykaufman/trustee/tree/addtpm) and the [guest component](https://github.com/iroykaufman/guest-components/tree/TPM-as-additional-device) to support the TPM as an additional device.
4450

45-
1. The guest component encrypts the public part of the AK in ASN.1 format, but trustee unmarshals it. The unmarshal part was replaced with an ASN.1 decrypt method.
46-
2. The TPM verifier does not check the nonce in the TPM because the `report_data` contains a digest of the `runtime_data` instead of the nonce. This is because the TPM is an additional device. This is a temporary solution.
51+
The changes in the guest component are also included in [PR#1093](https://github.com/confidential-containers/guest-components/pull/1093), and the changes in Trustee are related to [PR#851](https://github.com/confidential-containers/trustee/pull/851), where the most significant change is the removal of the trusted Attestation Key (AK) list.
4752

48-
49-
The changes in the guest component are included in this [PR#1093](https://github.com/confidential-containers/guest-components/pull/1093).
53+
This uses a modified version of `clevis-pin-trustee` that adds AK before performing attestation. The source code is available here: [clevis-pin-trustee](https://github.com/iroykaufman/clevis-pin-trustee/tree/create-tpm-ak)
5054

5155
## Attestation Policy
5256

@@ -57,7 +61,3 @@ The policy only checks hardware for both SEV-SNP and TPM.
5761
Verify that both devices are affirming and exist.
5862

5963

60-
## Demo
61-
62-
[![asciicast](https://asciinema.org/a/nsdsarO2ZTbXFjbh0wuNlohMt.svg)](https://asciinema.org/a/nsdsarO2ZTbXFjbh0wuNlohMt)
63-

trustee-on-GCP/rh-coreos/Containerfile

Lines changed: 0 additions & 18 deletions
This file was deleted.

trustee-on-GCP/rh-coreos/luks.bu

Lines changed: 0 additions & 44 deletions
This file was deleted.

trustee-on-GCP/rh-coreos/usr/lib/dracut/dracut.conf.d/50noxattr.conf

Lines changed: 0 additions & 1 deletion
This file was deleted.

trustee-on-GCP/rh-coreos/usr/lib/dracut/dracut.conf.d/50trustee.conf

Lines changed: 0 additions & 1 deletion
This file was deleted.

trustee-on-GCP/rh-coreos/usr/lib/dracut/modules.d/65aaclient/module-setup.sh

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
 (0)