| 1 |
.. _eif: |
| 2 |
|
| 3 |
Build an AWS Nitro Enclave |
| 4 |
============================== |
| 5 |
|
| 6 |
.. sidebar:: Abstract |
| 7 |
|
| 8 |
This page explains how to build AWS Nitro Enclaves. It covers the following topics: |
| 9 |
|
| 10 |
* how to build an AWS Nitro Enclave |
| 11 |
* how to test the enclave via QEMU |
| 12 |
|
| 13 |
AWS Nitro Enclaves enables customers to create isolated compute environments |
| 14 |
to further protect and securely process highly sensitive data such as personally |
| 15 |
identifiable information (PII), healthcare, financial, and intellectual property |
| 16 |
data within their Amazon EC2 instances. Nitro Enclaves uses the same Nitro |
| 17 |
Hypervisor technology that provides CPU and memory isolation for EC2 instances. |
| 18 |
For further details, please visit https://aws.amazon.com/ec2/nitro/nitro-enclaves. |
| 19 |
|
| 20 |
To add an enclave build to your appliance, create a `type` element with |
| 21 |
`image` set to `enclave` in the :file:`config.xml` file, as shown below: |
| 22 |
|
| 23 |
.. code:: xml |
| 24 |
|
| 25 |
<image schemaversion="{schema_version}" name="kiwi-test-image-nitro-enclave"> |
| 26 |
<!-- snip --> |
| 27 |
<profiles> |
| 28 |
<profile name="default" description="CPIO: default profile" import="true"/> |
| 29 |
<profile name="std" description="KERNEL: default kernel" import="true"/> |
| 30 |
</profiles> |
| 31 |
<preferences> |
| 32 |
<type image="enclave" enclave_format="aws-nitro" kernelcmdline="reboot=k panic=30 pci=off console=ttyS0 i8042.noaux i8042.nomux i8042.nopnp i8042.dumbkbd random.trust_cpu=on rdinit=/sbin/init"/> |
| 33 |
<!-- additional preferences --> |
| 34 |
</preferences> |
| 35 |
<packages type="image" profiles="std"> |
| 36 |
<package name="kernel"/> |
| 37 |
</packages> |
| 38 |
<!-- more packages --> |
| 39 |
<!-- snip --> |
| 40 |
</image> |
| 41 |
|
| 42 |
The following attributes of the `type` element are relevant: |
| 43 |
|
| 44 |
- `enclave_format`: Specifies the enclave target. |
| 45 |
|
| 46 |
As of today, only the `aws-nitro` enclave target is supported. |
| 47 |
|
| 48 |
|
| 49 |
- `kernelcmdline`: Specifies the kernel commandline suitable for the enclave. |
| 50 |
|
| 51 |
An enclave is a system that runs completely in RAM, loaded from |
| 52 |
an enclave binary format that includes the kernel, initrd, and |
| 53 |
the kernel command line suitable for the target system. |
| 54 |
|
| 55 |
With the appropriate settings specified in :file:`config.xml`, you can build an |
| 56 |
image using {kiwi}: |
| 57 |
|
| 58 |
.. code:: bash |
| 59 |
|
| 60 |
$ sudo kiwi-ng system build \ |
| 61 |
--description kiwi/build-tests/{exc_description_enclave} \ |
| 62 |
--set-repo {exc_repo_rawhide} \ |
| 63 |
--target-dir /tmp/myimage |
| 64 |
|
| 65 |
The resulting image is saved in :file:`/tmp/myimage`, and the image can |
| 66 |
be tested with QEMU: |
| 67 |
|
| 68 |
.. code:: bash |
| 69 |
|
| 70 |
$ sudo qemu-system-x86_64 \ |
| 71 |
-M nitro-enclave,vsock=c \ |
| 72 |
-m 4G \ |
| 73 |
-nographic \ |
| 74 |
-chardev socket,id=c,path=/tmp/vhost4.socket \ |
| 75 |
-kernel {exc_image_base_name_enclave}.eif |
| 76 |
|
| 77 |
The image is now complete and ready to use. Access to the system is |
| 78 |
possible via ssh through a vsock connection into the guest. To establish |
| 79 |
a vsock connection, it's required to forward the connection through the |
| 80 |
guest's `AF_VSOCK` socket. This can be done via a `ProxyCommand` setup of the |
| 81 |
host's ssh as follows: |
| 82 |
|
| 83 |
.. code:: bash |
| 84 |
|
| 85 |
$ vi ~/bin/vsock-ssh.sh |
| 86 |
|
| 87 |
#!/bin/bash |
| 88 |
CID=$(echo "$1" | cut -d . -f 1) |
| 89 |
socat - VSOCK-CONNECT:$CID:22 |
| 90 |
|
| 91 |
.. code:: bash |
| 92 |
|
| 93 |
$ vi ~/.ssh/config |
| 94 |
|
| 95 |
host *.vsock |
| 96 |
ProxyCommand ~/bin/vsock-ssh.sh %h |
| 97 |
|
| 98 |
After the ssh proxy setup, log in to the enclave with a custom vsock port |
| 99 |
as follows: |
| 100 |
|
| 101 |
.. code:: bash |
| 102 |
|
| 103 |
$ ssh [email protected] |