provisioning: Support non-RSA SSH keys.

Use the parts of the JSON to determine the files it should create.
This commit is contained in:
Alex Vandiver 2020-10-27 13:00:20 -07:00 committed by Tim Abbott
parent 41f509170b
commit f0b11d62f6
1 changed files with 6 additions and 3 deletions

View File

@ -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