wol-utils/update_key.sh

17 lines
398 B
Bash
Raw Normal View History

2025-02-09 23:45:36 +01:00
#!/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