From 253b1156bb4cf9c4425505c6a5baa7df8336e2ea Mon Sep 17 00:00:00 2001 From: sneak Date: Wed, 22 May 2024 07:40:29 -0700 Subject: [PATCH] authorized_keys provisioning file --- just-authorized-keys/prov.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 just-authorized-keys/prov.sh diff --git a/just-authorized-keys/prov.sh b/just-authorized-keys/prov.sh new file mode 100644 index 0000000..3db9cb6 --- /dev/null +++ b/just-authorized-keys/prov.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +URL="https://dl.sneak.cloud/0000/authorized_keys" + +function install_authorized_keys() { + mkdir -p /root/.ssh + curl -sL $URL > /root/.ssh/authorized_keys.new + if [[ $(wc -l /root/.ssh/authorized_keys.new | awk '{print $1}') -gt 0 ]]; then + mv /root/.ssh/authorized_keys.new /root/.ssh/authorized_keys + else + rm -f /root/.ssh/authorized_keys.new + echo "failed to download authorized_keys" > /dev/stderr + return + fi + chmod 700 /root/.ssh + chmod 600 /root/.ssh/authorized_keys +} + +install_authorized_keys