-
Notifications
You must be signed in to change notification settings - Fork 10
Local deployment with Trustee and AK registration #50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 10 commits
4c04c06
ca26ec6
80e9fe7
a3fb606
771573a
7132e07
a04ab80
f777f4c
f722849
1e40ebf
82ad862
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| variant: fcos | ||
| version: 1.7.0-experimental | ||
|
|
||
| ignition: | ||
| config: | ||
| merge: | ||
| - source: http://<IP>:8000/pin-trustee.ign | ||
|
|
||
| attestation: | ||
| attestation_key: | ||
| registration: | ||
| url: http://<IP>:5001 | ||
|
|
||
| passwd: | ||
| users: | ||
| - name: core | ||
| ssh_authorized_keys: | ||
| - <KEY> | ||
|
|
||
| systemd: | ||
| units: | ||
| - name: zincati.service | ||
| enabled: false | ||
| - name: [email protected] | ||
| dropins: | ||
| - name: autologin-core.conf | ||
| contents: | | ||
| [Service] | ||
| # Override Execstart in main unit | ||
| ExecStart= | ||
| # Add new Execstart with `-` prefix to ignore failure` | ||
| ExecStart=-/usr/sbin/agetty --autologin core --noclear %I $TERM | ||
|
|
||
| storage: | ||
| files: | ||
| - path: /etc/profile.d/systemd-pager.sh | ||
| mode: 0644 | ||
| contents: | ||
| inline: | | ||
| # Tell systemd to not use a pager when printing information | ||
| export SYSTEMD_PAGER=cat |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| variant: fcos | ||
| version: 1.6.0 | ||
| version: 1.7.0-experimental | ||
| storage: | ||
| luks: | ||
| - name: root | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| #!/bin/bash | ||
|
|
||
| check() { | ||
| return 0 | ||
| } | ||
|
|
||
| depends() { | ||
| return 0 | ||
| } | ||
|
|
||
| install () { | ||
| inst_multiple \ | ||
| tpm2_create \ | ||
| tpm2_createak \ | ||
| tpm2_evictcontrol \ | ||
| tpm2_getrandom \ | ||
| tpm2_load \ | ||
| tpm2_nvread \ | ||
| tpm2_nvwrite \ | ||
| tpm2_pcrread \ | ||
| tpm2_unseal | ||
|
|
||
| # Library dependencies | ||
| inst_libdir_file "libtss2*" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| #!/bin/bash | ||
|
|
||
| create_remote_ign_config () | ||
| { | ||
| IP=$1 | ||
| # Setup remote ignition config | ||
| BUTANE=pin-trustee.bu | ||
| IGNITION="${BUTANE%.bu}.ign" | ||
|
|
||
| sed "s/<IP>/$IP/" configs/remote-ign/${BUTANE} > tmp/${BUTANE} | ||
|
|
||
| podman run --interactive --rm --security-opt label=disable \ | ||
| --volume "$(pwd)/tmp:/pwd" \ | ||
| --workdir /pwd \ | ||
| quay.io/confidential-clusters/butane:clevis-pin-trustee \ | ||
| --pretty --strict /pwd/$BUTANE --output "/pwd/$IGNITION" | ||
| echo "$IGNITION" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| #!/bin/bash | ||
|
|
||
| DIR=trustee/keys | ||
| mkdir -p "$DIR" | ||
|
|
||
| openssl genpkey -algorithm ed25519 > $DIR/private.key | ||
| openssl pkey -in $DIR/private.key -pubout -out $DIR/public.pub |
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I put it in a common script to be sourced |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -ex | ||
|
|
||
| KBC=kbs-client | ||
| URL=http://localhost:8080 | ||
| KEY=trustee/keys/private.key | ||
|
|
||
| cat <<EOF >secret | ||
| { "key_type": "oct", "key": "2b442dd5db4478367729ef8bbf2e7480" } | ||
| EOF | ||
|
|
||
| $KBC --url $URL config \ | ||
| --auth-private-key $KEY \ | ||
| set-resource --path default/machine/root \ | ||
| --resource-file $(pwd)/secret | ||
|
|
||
| $KBC --url http://localhost:8080 config \ | ||
| --auth-private-key $KEY \ | ||
| set-resource-policy --allow-all | ||
|
|
||
|
|
||
| cat <<EOF >attestation-policy.rego | ||
| package policy | ||
| import rego.v1 | ||
| default hardware := 97 | ||
| default configuration := 36 | ||
| default executables := 33 | ||
|
|
||
| tpm_pcrs_valid if { | ||
| input.tpm.pcr04 in data.reference.tpm_pcr4 | ||
| input.tpm.pcr07 in data.reference.tpm_pcr7 | ||
| input.tpm.pcr14 in data.reference.tpm_pcr14 | ||
| } | ||
|
|
||
| hardware := 2 if tpm_pcrs_valid | ||
| executables := 3 if tpm_pcrs_valid | ||
| configuration := 2 if tpm_pcrs_valid | ||
|
|
||
| default file_system := 0 | ||
| default instance_identity := 0 | ||
| default runtime_opaque := 0 | ||
| default storage_opaque := 0 | ||
| default sourced_data := 0 | ||
| result := { | ||
| "executables": executables, | ||
| "hardware": hardware, | ||
| "configuration": configuration, | ||
| "file-system": file_system, | ||
| "instance-identity": instance_identity, | ||
| "runtime-opaque": runtime_opaque, | ||
| "storage-opaque": storage_opaque, | ||
| "sourced-data": sourced_data, | ||
| } | ||
| EOF | ||
|
|
||
| $KBC --url $URL config \ | ||
| --auth-private-key $KEY \ | ||
| set-sample-reference-value tpm_pcr4 "ff2b357be4a4bc66be796d4e7b2f1f27077dc89b96220aae60b443bcf4672525" | ||
| $KBC --url $URL config \ | ||
| --auth-private-key $KEY \ | ||
| set-sample-reference-value tpm_pcr7 "b3a56a06c03a65277d0a787fcabc1e293eaa5d6dd79398f2dda741f7b874c65d" | ||
| $KBC --url $URL config \ | ||
| --auth-private-key $KEY \ | ||
| set-sample-reference-value tpm_pcr14 "17cdefd9548f4383b67a37a901673bf3c8ded6f619d36c8007562de1d93c81cc" | ||
|
|
||
| $KBC --url $URL config \ | ||
| --auth-private-key $KEY \ | ||
| get-reference-values | ||
| $KBC --url $URL config \ | ||
| --auth-private-key $KEY \ | ||
| set-attestation-policy --policy-file attestation-policy.rego --id default_cpu --type rego |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| FROM python:3.11-slim | ||
|
|
||
| WORKDIR /app | ||
|
|
||
| COPY server.py . | ||
|
|
||
| EXPOSE 5001 | ||
|
|
||
| CMD ["python", "server.py"] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| from http.server import HTTPServer, BaseHTTPRequestHandler | ||
| import json | ||
| import sys | ||
| import os | ||
|
|
||
| class PUTHandler(BaseHTTPRequestHandler): | ||
| def do_PUT(self): | ||
| content_length = int(self.headers['Content-Length']) | ||
| body = self.rfile.read(content_length) | ||
| print(body) | ||
| try: | ||
| data = json.loads(body) | ||
|
|
||
| attestation_key = data.get('attestation_key', '') | ||
|
|
||
| if not os.path.exists('/data/test.pub'): | ||
| os.makedirs('/data', exist_ok=True) | ||
| open('/data/test.pub', 'a').close() | ||
| print("Created /data/test.pub") | ||
|
|
||
| with open('/data/test.pub', 'w') as f: | ||
| f.write(attestation_key) | ||
|
|
||
| print(f"Successfully wrote attestation key to /data/test.pub") | ||
|
|
||
| self.send_response(200) | ||
| self.send_header('Content-type', 'application/json') | ||
| self.end_headers() | ||
| self.wfile.write(json.dumps({'status': 'success'}).encode()) | ||
| except Exception as e: | ||
| print(f"Error: {e}") | ||
| self.send_response(500) | ||
| self.send_header('Content-type', 'application/json') | ||
| self.end_headers() | ||
| self.wfile.write(json.dumps({'status': 'error', 'message': str(e)}).encode()) | ||
|
|
||
| if __name__ == '__main__': | ||
| server = HTTPServer(('0.0.0.0', 5001), PUTHandler) | ||
| print('Server running on port 5001...') | ||
| server.serve_forever() |
Uh oh!
There was an error while loading. Please reload this page.