Skip to content

Commit da9a77c

Browse files
author
Quentin Perez
committed
Expose server SSH Keys fingerprint scaleway#36
1 parent 216b977 commit da9a77c

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

skeleton-common/usr/local/sbin/oc-generate-ssh-keys

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ then
1111
ssh-keygen -t ed25519 -N '' -f /etc/ssh/ssh_host_ed25519_key || true &
1212
wait `jobs -p` || true
1313
fi
14+
oc-userdata ssh-host-fingerprints "`cat /etc/ssh/ssh_host_*pub`" binary

skeleton-common/usr/local/sbin/oc-userdata

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,26 @@ get() {
1414
RESPONSE=$(curl --local-port 1-1024 --silent --write-out "\n%{http_CODE}\n" $URL)
1515
CODE=$(echo "$RESPONSE" | sed -n '$p')
1616
BODY=$(echo "$RESPONSE" | sed '$d')
17-
echo "$BODY"
17+
echo "$BODY"
1818
else
19-
echo "'curl' dependency is missing." >&2
19+
echo "'curl' dependency is missing." >&2
2020
fi
2121
}
2222

2323
patch() {
2424
URL="$1"
2525
DATA="$2"
26+
TYPEDATA="-d"
27+
28+
if [ "$3" = "binary" ]; then
29+
TYPEDATA="--data-binary"
30+
fi
31+
2632
if type curl >/dev/null 2>/dev/null; then
2733
# Using curl
28-
RESPONSE=$(curl --local-port 1-1024 -X PATCH -d "$DATA" -H "Content-Type: text/plain" --silent --write-out "\n%{http_CODE}\n" $URL)
34+
RESPONSE=$(curl --local-port 1-1024 -X PATCH $TYPEDATA "$DATA" -H "Content-Type: text/plain" --silent --write-out "\n%{http_CODE}\n" $URL)
2935
else
30-
echo "'curl' dependency is missing." >&2
36+
echo "'curl' dependency is missing." >&2
3137
fi
3238
}
3339

@@ -37,6 +43,6 @@ else
3743
if [ "$2" = "" ]; then
3844
get "$USERDATA_URL/$1"
3945
else
40-
patch "$USERDATA_URL/$1" "$2"
46+
patch "$USERDATA_URL/$1" "$2" $3
4147
fi
4248
fi

0 commit comments

Comments
 (0)