From f0b11d62f669b70c540f9b0e4d806d7e38b3afc4 Mon Sep 17 00:00:00 2001 From: Alex Vandiver Date: Tue, 27 Oct 2020 13:00:20 -0700 Subject: [PATCH] provisioning: Support non-RSA SSH keys. Use the parts of the JSON to determine the files it should create. --- tools/setup/bootstrap-aws-installer | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tools/setup/bootstrap-aws-installer b/tools/setup/bootstrap-aws-installer index 6d12e264de..d407b77e85 100644 --- a/tools/setup/bootstrap-aws-installer +++ b/tools/setup/bootstrap-aws-installer @@ -63,10 +63,13 @@ function install_keys() { --secret-id "$SSH_SECRET_ID" \ --query SecretString)" mkdir -p "$SSHDIR" - echo "$KEYDATA" | jq -r .public | base64 -d >"$SSHDIR/id_rsa.pub" - echo "$KEYDATA" | jq -r .private | base64 -d >"$SSHDIR/id_rsa" + for KEYFILE in $(echo "$KEYDATA" | jq -r 'keys[]'); do + echo "$KEYDATA" | jq -r ".[\"$KEYFILE\"]" | base64 -d >"$SSHDIR/$KEYFILE" + if [[ "$KEYFILE" != *".pub" ]]; then + chmod 600 "$SSHDIR/$KEYFILE" + fi + done chown -R "$USERNAME:$USERNAME" "$SSHDIR" - chmod 600 "$SSHDIR/id_rsa" } install_keys root