From fa7a205eb7ed93fda5280a1b9070607ed9cd46f4 Mon Sep 17 00:00:00 2001 From: Michiel Berger Date: Thu, 30 Apr 2026 15:02:47 +0200 Subject: [PATCH] deploy.sh: auto-refresh SSH host key when h4a recreates the VM --- scripts/deploy.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/deploy.sh b/scripts/deploy.sh index 2cc63ee..8ac3d2a 100755 --- a/scripts/deploy.sh +++ b/scripts/deploy.sh @@ -12,7 +12,10 @@ set -euo pipefail ALIAS="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' echo "→ rsyncing source to ${ALIAS}:${APP_DIR}"