wol-utils/update_key.sh
2025-02-09 23:45:36 +01:00

16 lines
398 B
Bash

#!/bin/sh
set -xeuo pipefail
TMP_FILE=".ssh/authorized_keys.tmp"
CMD="$HOME/wol.sh"
truncate --size 0 $TMP_FILE
for target in $(cat operators | sed 's/curl \([^ ]*\).gpg .*/\1.keys/'); do
curl "$target" | sed 's#.*#command="'"$CMD"'" \0 '"$target"'#' >> $TMP_FILE
done
cat additional_keys | sed 's#.*#command="'"$CMD"'" \0#' >> $TMP_FILE
chmod 600 $TMP_FILE
mv $TMP_FILE .ssh/authorized_keys