deploy.sh: auto-refresh SSH host key when h4a recreates the VM

This commit is contained in:
Michiel Berger 2026-04-30 15:02:47 +02:00
parent 1d7574e0b2
commit fa7a205eb7

View file

@ -12,7 +12,10 @@ set -euo pipefail
ALIAS="thuisbatterij" ALIAS="thuisbatterij"
APP_DIR="/opt/thuisbatterij" APP_DIR="/opt/thuisbatterij"
echo "→ checking SSH" echo "→ checking SSH (auto-refreshing host key if h4a recreated the VM)"
HOST=$(awk -v a="${ALIAS}" '$1=="Host"{h=$2} h==a&&$1=="HostName"{print $2; exit}' "${HOME}/.ssh/config")
ssh-keygen -R "${HOST}" >/dev/null 2>&1 || true
ssh-keyscan -t ed25519,rsa "${HOST}" 2>/dev/null >> "${HOME}/.ssh/known_hosts"
ssh -o BatchMode=yes -o ConnectTimeout=8 ${ALIAS} 'true' ssh -o BatchMode=yes -o ConnectTimeout=8 ${ALIAS} 'true'
echo "→ rsyncing source to ${ALIAS}:${APP_DIR}" echo "→ rsyncing source to ${ALIAS}:${APP_DIR}"