forked from kalipso/infrastructure
[scripts] make pwpath consistant
This commit is contained in:
@@ -16,16 +16,17 @@ if [ ! -e flake.nix ]
|
|||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
pwpath="machines"
|
read -p "Enter new host name: " hostname
|
||||||
hostkey="ssh_host_ed25519_key"
|
|
||||||
initrdkey="initrd_ed25519_key"
|
|
||||||
read -p "Enter new host name: " host
|
|
||||||
|
|
||||||
if [ "$host" = "" ]; then exit 0
|
if [ "$hostname" = "" ]; then exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mkdir -p $pwpath/$host/secrets
|
pwpath="machines/$hostname/secrets"
|
||||||
cd $pwpath/$host/secrets
|
hostkey="ssh_host_ed25519_key"
|
||||||
|
initrdkey="initrd_ed25519_key"
|
||||||
|
|
||||||
|
mkdir -p "$pwpath"
|
||||||
|
cd "$pwpath"
|
||||||
|
|
||||||
# Generate SSH keys
|
# Generate SSH keys
|
||||||
ssh-keygen -f $hostkey -t ed25519 -N ""
|
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 "$(ssh-to-age -i ./"$hostkey".pub)"
|
||||||
echo
|
echo
|
||||||
echo "Hier ist eine reproduzierbare mac-addresse:"
|
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
|
exit 0
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ set -o errexit
|
|||||||
set -o pipefail
|
set -o pipefail
|
||||||
|
|
||||||
sshoptions="-o StrictHostKeyChecking=no -o ServerAliveInterval=1 -o ServerAliveCountMax=1 -p 222 -T"
|
sshoptions="-o StrictHostKeyChecking=no -o ServerAliveInterval=1 -o ServerAliveCountMax=1 -p 222 -T"
|
||||||
HOSTNAME=$1
|
hostname=$1
|
||||||
|
|
||||||
if [ ! -e flake.nix ]
|
if [ ! -e flake.nix ]
|
||||||
then
|
then
|
||||||
@@ -19,17 +19,17 @@ if [ ! -e flake.nix ]
|
|||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
diskkey=$(sops -d machines/$HOSTNAME/secrets/disk.key)
|
diskkey=$(sops -d machines/$hostname/secrets/disk.key)
|
||||||
|
|
||||||
echo
|
echo
|
||||||
if [ $# = 1 ]
|
if [ $# = 1 ]
|
||||||
then
|
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 ]
|
elif [ $# = 2 ]
|
||||||
then
|
then
|
||||||
IP=$2
|
ip=$2
|
||||||
echo "$diskkey" | ssh $sshoptions root@$IP "systemd-tty-ask-password-agent" #root
|
echo "$diskkey" | ssh $sshoptions root@$ip "systemd-tty-ask-password-agent" #root
|
||||||
|
|
||||||
else
|
else
|
||||||
echo
|
echo
|
||||||
|
|||||||
Reference in New Issue
Block a user