Don't worry why all the commit hashes suddenly changed, it's fine. Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
31 lines
731 B
Bash
Executable File
31 lines
731 B
Bash
Executable File
#!/usr/bin/env -S nix shell nixpkgs#ssh-to-age -c bash
|
|
# shellcheck shell=bash
|
|
|
|
set -o errexit
|
|
set -o nounset
|
|
set -o pipefail
|
|
|
|
if [[ "$#" -ne 1 ]]; then
|
|
echo "Usage: $0 <host>"
|
|
exit 1
|
|
fi
|
|
|
|
host="$1"
|
|
|
|
age_key=$(ssh-to-age < "./hosts/$host/secrets/ssh_host_ed25519_key.pub")
|
|
|
|
find . -type f -name "sops.yaml" | while IFS= read -r sops_file; do
|
|
sed -i "/ - &$host $age_key/d" "$sops_file"
|
|
sed -i "/ - \*$host/d" "$sops_file"
|
|
done
|
|
|
|
sed -i "/$host/d" ./hosts/common/configs/system/ssh/default.nix
|
|
sed -i "/$host/d" ./README.md
|
|
|
|
rm -rf "./hosts/$host"
|
|
|
|
"$(dirname "$0")/update-keys.sh"
|
|
|
|
echo "Please remove SSH key pairs for any users that used to connect to $host."
|
|
echo "Host $host has been successfully removed."
|