From c9bbb5e6fb3270ff0504a126f64b10fe09fea14f Mon Sep 17 00:00:00 2001 From: Richard Courtman Date: Sat, 18 Oct 2025 07:27:15 +0000 Subject: [PATCH] fix: use proxy SSH key for cleanup of standalone nodes - Cleanup script now tries proxy's SSH key first for standalone nodes - Falls back to default SSH if proxy key not available - Fixes cleanup failure when Proxmox host doesn't have direct SSH to standalone nodes --- scripts/install-sensor-proxy.sh | 11 ++++++++++- scripts/pulse-sensor-cleanup.sh | 11 ++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/scripts/install-sensor-proxy.sh b/scripts/install-sensor-proxy.sh index 34a567c..107116a 100755 --- a/scripts/install-sensor-proxy.sh +++ b/scripts/install-sensor-proxy.sh @@ -418,8 +418,17 @@ else else log_info "Cleaning up remote host: $HOST_CLEAN" + # Try to use proxy's SSH key first (for standalone nodes), fall back to default + PROXY_KEY="/var/lib/pulse-sensor-proxy/ssh/id_ed25519" + SSH_CMD="ssh -o StrictHostKeyChecking=no -o BatchMode=yes -o ConnectTimeout=5" + + if [[ -f "$PROXY_KEY" ]]; then + log_info "Using proxy SSH key for cleanup" + SSH_CMD="$SSH_CMD -i $PROXY_KEY" + fi + # Remove both pulse-managed-key and pulse-proxy-key entries from remote host - ssh -o StrictHostKeyChecking=no -o BatchMode=yes -o ConnectTimeout=5 root@"$HOST_CLEAN" \ + $SSH_CMD root@"$HOST_CLEAN" \ "sed -i -e '/# pulse-managed-key\$/d' -e '/# pulse-proxy-key\$/d' /root/.ssh/authorized_keys" 2>&1 | \ logger -t "$LOG_TAG" -p user.info diff --git a/scripts/pulse-sensor-cleanup.sh b/scripts/pulse-sensor-cleanup.sh index 23534ad..8ea979b 100644 --- a/scripts/pulse-sensor-cleanup.sh +++ b/scripts/pulse-sensor-cleanup.sh @@ -105,8 +105,17 @@ else else log_info "Cleaning up remote host: $HOST_CLEAN" + # Try to use proxy's SSH key first (for standalone nodes), fall back to default + PROXY_KEY="/var/lib/pulse-sensor-proxy/ssh/id_ed25519" + SSH_CMD="ssh -o StrictHostKeyChecking=no -o BatchMode=yes -o ConnectTimeout=5" + + if [[ -f "$PROXY_KEY" ]]; then + log_info "Using proxy SSH key for cleanup" + SSH_CMD="$SSH_CMD -i $PROXY_KEY" + fi + # Remove both pulse-managed-key and pulse-proxy-key entries from remote host - ssh -o StrictHostKeyChecking=no -o BatchMode=yes -o ConnectTimeout=5 root@"$HOST_CLEAN" \ + $SSH_CMD root@"$HOST_CLEAN" \ "sed -i -e '/# pulse-managed-key\$/d' -e '/# pulse-proxy-key\$/d' /root/.ssh/authorized_keys" 2>&1 | \ logger -t "$LOG_TAG" -p user.info