1
0
mirror of https://gitlab.alpinelinux.org/alpine/cloud/tiny-cloud.git synced 2026-02-04 04:22:43 +03:00
Jake Buchholz Göktürk 78650078d1 per-login GCP SSH keys
2025-12-05 19:05:45 -08:00

29 lines
619 B
Bash

# Google Cloud Instance MetaData Service variables and functions
# vim:set filetype=sh:
# shellcheck shell=sh
IMDS_HEADER="Metadata-Flavor"
IMDS_URI="computeMetadata/v1"
IMDS_HOSTNAME="instance/hostname"
IMDS_LOCAL_HOSTNAME="$IMDS_HOSTNAME"
IMDS_SSH_KEYS="
project/attributes/ssh-keys
instance/attributes/ssh-keys
"
IMDS_USERDATA="instance/attributes/user-data"
_imds_header() {
echo "$IMDS_HEADER: Google"
}
# merge project and instance keys
_imds_ssh_keys() {
local ssh_keys
# NOTE:keys are prefixed with "<login>:"
for ssh_keys in $IMDS_SSH_KEYS; do
imds -e "$ssh_keys" | cut -d: -f2-
done | sort -u
}