From 2297dec03d01b51aec2569355f632b88249a6dde Mon Sep 17 00:00:00 2001 From: ahtlon Date: Sun, 23 Feb 2025 13:16:17 +0100 Subject: [PATCH] [scripts] make pwpath consistant --- scripts/add_new_host_keys.sh | 17 +++++++++-------- scripts/unlock-boot.sh | 10 +++++----- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/scripts/add_new_host_keys.sh b/scripts/add_new_host_keys.sh index b8db4770..8fcce666 100755 --- a/scripts/add_new_host_keys.sh +++ b/scripts/add_new_host_keys.sh @@ -16,16 +16,17 @@ if [ ! -e flake.nix ] done fi -pwpath="machines" -hostkey="ssh_host_ed25519_key" -initrdkey="initrd_ed25519_key" -read -p "Enter new host name: " host +read -p "Enter new host name: " hostname -if [ "$host" = "" ]; then exit 0 +if [ "$hostname" = "" ]; then exit 0 fi -mkdir -p $pwpath/$host/secrets -cd $pwpath/$host/secrets +pwpath="machines/$hostname/secrets" +hostkey="ssh_host_ed25519_key" +initrdkey="initrd_ed25519_key" + +mkdir -p "$pwpath" +cd "$pwpath" # Generate SSH keys ssh-keygen -f $hostkey -t ed25519 -N "" @@ -45,6 +46,6 @@ echo "Hier ist der age public key für sops etc:" echo "$(ssh-to-age -i ./"$hostkey".pub)" echo echo "Hier ist eine reproduzierbare mac-addresse:" -echo "$host"|md5sum|sed 's/^\(..\)\(..\)\(..\)\(..\)\(..\).*$/02:\1:\2:\3:\4:\5/' +echo "$hostname"|md5sum|sed 's/^\(..\)\(..\)\(..\)\(..\)\(..\).*$/02:\1:\2:\3:\4:\5/' exit 0 diff --git a/scripts/unlock-boot.sh b/scripts/unlock-boot.sh index e00afc8e..b0d82706 100644 --- a/scripts/unlock-boot.sh +++ b/scripts/unlock-boot.sh @@ -2,7 +2,7 @@ set -o errexit set -o pipefail sshoptions="-o StrictHostKeyChecking=no -o ServerAliveInterval=1 -o ServerAliveCountMax=1 -p 222 -T" -HOSTNAME=$1 +hostname=$1 if [ ! -e flake.nix ] then @@ -19,17 +19,17 @@ if [ ! -e flake.nix ] done fi -diskkey=$(sops -d machines/$HOSTNAME/secrets/disk.key) +diskkey=$(sops -d machines/$hostname/secrets/disk.key) echo if [ $# = 1 ] then - echo "$diskkey" | ssh $sshoptions root@$HOSTNAME-initrd "systemd-tty-ask-password-agent" #root + echo "$diskkey" | ssh $sshoptions root@$hostname-initrd "systemd-tty-ask-password-agent" #root elif [ $# = 2 ] then - IP=$2 - echo "$diskkey" | ssh $sshoptions root@$IP "systemd-tty-ask-password-agent" #root + ip=$2 + echo "$diskkey" | ssh $sshoptions root@$ip "systemd-tty-ask-password-agent" #root else echo