From: Michael Tremer Date: Tue, 29 Sep 2020 08:05:44 +0000 (+0000) Subject: exoscale: Get SSH key from meta-data API X-Git-Url: http://git.ipfire.org/?p=people%2Fpmueller%2Fipfire-2.x.git;a=commitdiff_plain;h=a7d8d35288d72a958e5d961bbaed10c4d950eafd exoscale: Get SSH key from meta-data API Signed-off-by: Michael Tremer --- diff --git a/src/initscripts/helper/exoscale-setup b/src/initscripts/helper/exoscale-setup index bc2f8a2827..59859a6e92 100644 --- a/src/initscripts/helper/exoscale-setup +++ b/src/initscripts/helper/exoscale-setup @@ -49,22 +49,17 @@ import_exoscale_configuration() { usermod -p "x" setup fi - # Import SSH keys for setup user - local line - for line in $(get "meta-data/public-keys/"); do - local key_no="${line%=*}" - - local key="$(get meta-data/public-keys/${key_no}/openssh-key)" - if [ -n "${key}" ] && ! grep -q "^${key}$" "/home/setup/.ssh/authorized_keys" 2>/dev/null; then - mkdir -p "/home/setup/.ssh" - chmod 700 "/home/setup/.ssh" - chown setup.nobody "/home/setup/.ssh" - - echo "${key}" >> "/home/setup/.ssh/authorized_keys" - chmod 600 "/home/setup/.ssh/authorized_keys" - chown setup.nobody "/home/setup/.ssh/authorized_keys" - fi - done + # Import SSH key for setup user + local key=$(get "meta-data/public-keys") + if [ -n "${key}" ] && ! grep -q "^${key}$" "/home/setup/.ssh/authorized_keys" 2>/dev/null; then + mkdir -p "/home/setup/.ssh" + chmod 700 "/home/setup/.ssh" + chown setup.nobody "/home/setup/.ssh" + + echo "${key}" >> "/home/setup/.ssh/authorized_keys" + chmod 600 "/home/setup/.ssh/authorized_keys" + chown setup.nobody "/home/setup/.ssh/authorized_keys" + fi # Download the user-data script only on the first boot if [ ! -e "/var/ipfire/main/firstsetup_ok" ]; then