From c600e69a8bf983dd323e901a089c35d1c7447bb2 Mon Sep 17 00:00:00 2001 From: "Lance R. Vick" Date: Fri, 7 Jul 2023 12:21:32 -0700 Subject: [PATCH 1/3] initial debug tips doc --- docs/debug-tips.md | 61 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 docs/debug-tips.md diff --git a/docs/debug-tips.md b/docs/debug-tips.md new file mode 100644 index 00000000..f644c6aa --- /dev/null +++ b/docs/debug-tips.md @@ -0,0 +1,61 @@ +## Setup nitro dev box + +1. launch latest debian AMI +2. Configure custom nitro kernel + ``` + ssh -A admin@ + sudo -s + apt install -y tmux dpkg-dev pahole inotify-tools neovim build-essential linux-source-6.1.0 + cd /usr/src + tar -xvf linux-source-6.1.tar.xz + cd linux-source-6.1 + cp /boot/config-$(uname -r) . + scripts/config --disable SYSTEM_TRUSTED_KEYS + scripts/config --disable SYSTEM_REVOCATION_KEYS + scripts/config --module NITRO_ENCLAVES + make deb-pkg LOCALVERSION=-nitro KDEB_PKGVERSION=$(make kernelversion)-1 + dpkg -i ../linux-image-6.1.37-nitro_6.1.37-1_amd64.deb + reboot + ``` +3. Configure Nitro Enclave tooling + ``` + ssh -A admin@ + git clone https://github.com/aws/aws-nitro-enclaves-cli.git + cd aws-nitro-enclaves-cli + make + sudo mkdir -p /run/nitro_enclaves /etc/nitro_enclaves /var/log/nitro_enclaves + sudo chmod -R g+w /var/log/nitro_enclaves /run/nitro_enclaves /etc/nitro_enclaves + sudo chown -R :admin /var/log/nitro_enclaves /run/nitro_enclaves /etc/nitro_enclaves + sudo cp build/nitro_cli/x86_64-unknown-linux-musl/release/nitro-cli /usr/local/bin/ + sudo cp bootstrapnitro-enclaves-allocator /usr/local/bin/ + sudo cp bootstrap/allocator.yaml /etc/ + sed -i 's|/usr/bin|/usr/local/bin|g' bootstrap/nitro-enclaves-allocator.service + sudo cp bootstrap/nitro-enclaves-allocator.service /etc/systemd/system/ + sudo systemctl enable nitro-enclaves-allocator.service + ``` + +## Terminate enclaves automatically when new EIF file is written + +``` +while inotifywait -e close_write out/aws-x86_64.eif; do sudo nitro-cli terminate-enclave --all; done +``` + +## Run debug enclave with nitro-cli in a loop: +``` +while sleep 1; do sudo nitro-cli run-enclave --enclave-name nitro --memory 1024 --enclave-cid 16 --cpu-count 2 --eif-path out/aws-x86_64.eif --debug-mode --attach-console; done +``` + +## manually run qos_host: +``` +./dist/qos_host.linux-x86_64 --host-ip 0.0.0.0 --host-port 3000 --cid 16 --port 3 +``` + +## run health check in loop: +``` +while sleep 1; do clear; date; curl localhost:3000/qos/enclave-health; done +``` + +## Vim command to save and trigger new enclave build/launch: +``` +:w|! time make out/aws-x86_64.eif +``` From 831323e24b46a7a94c97190ac5b2df5d8f63fcce Mon Sep 17 00:00:00 2001 From: "Lance R. Vick" Date: Fri, 7 Jul 2023 12:26:56 -0700 Subject: [PATCH 2/3] include docker setup --- docs/debug-tips.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/docs/debug-tips.md b/docs/debug-tips.md index f644c6aa..8ce99f04 100644 --- a/docs/debug-tips.md +++ b/docs/debug-tips.md @@ -17,7 +17,19 @@ dpkg -i ../linux-image-6.1.37-nitro_6.1.37-1_amd64.deb reboot ``` -3. Configure Nitro Enclave tooling +3. Setup latest docker + ``` + sudo install -m 0755 -d /etc/apt/keyrings + curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg + sudo chmod a+r /etc/apt/keyrings/docker.gpg + echo \ + "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \ + "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \ + sudo tee /etc/apt/sources.list.d/docker.list > /dev/null + sudo apt update + sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin + ``` +4. Configure Nitro Enclave tooling ``` ssh -A admin@ git clone https://github.com/aws/aws-nitro-enclaves-cli.git From 968113ba72e2fd4d7125cd276be3ac0af8d9f0f4 Mon Sep 17 00:00:00 2001 From: "Lance R. Vick" Date: Fri, 7 Jul 2023 12:29:55 -0700 Subject: [PATCH 3/3] document ssh connection --- docs/debug-tips.md | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/docs/debug-tips.md b/docs/debug-tips.md index 8ce99f04..d012f04f 100644 --- a/docs/debug-tips.md +++ b/docs/debug-tips.md @@ -1,9 +1,14 @@ ## Setup nitro dev box -1. launch latest debian AMI -2. Configure custom nitro kernel +1. Launch latest Debian AMI +2. Connect to instance + ``` + while sleep 1; do ssh admin@; done + ``` +3. Configure custom nitro kernel + + Assumes kernel "6.1" is latest. Adjust accordingly. ``` - ssh -A admin@ sudo -s apt install -y tmux dpkg-dev pahole inotify-tools neovim build-essential linux-source-6.1.0 cd /usr/src @@ -17,7 +22,7 @@ dpkg -i ../linux-image-6.1.37-nitro_6.1.37-1_amd64.deb reboot ``` -3. Setup latest docker +4. Setup latest docker ``` sudo install -m 0755 -d /etc/apt/keyrings curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg @@ -29,9 +34,8 @@ sudo apt update sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin ``` -4. Configure Nitro Enclave tooling +5. Configure Nitro Enclave tooling ``` - ssh -A admin@ git clone https://github.com/aws/aws-nitro-enclaves-cli.git cd aws-nitro-enclaves-cli make