This commit is contained in:
2026-03-24 01:22:05 +00:00
parent 21de9b39dc
commit 312f8d251f
2 changed files with 31 additions and 22 deletions
+13 -2
View File
@@ -66,7 +66,7 @@ require_var() {
fi
}
# 🔥 Host + SSH Detection (THE IMPORTANT FIX)
# Detect hosts + SSH key + Tailscale IP
detect_hosts() {
LOCAL_HOSTNAME="$(hostname)"
@@ -86,13 +86,24 @@ detect_hosts() {
# Resolve Tailscale IP
REMOTE_SERVER=$(tailscale ip -4 "$REMOTE_SERVER_NAME" 2>/dev/null)
if [[ -z "$REMOTE_SERVER" ]]; then
echo "Error: Could not resolve Tailscale IP for $REMOTE_SERVER_NAME"
exit 1
fi
# Assign SSH key
# Validate SSH_KEYS
if [[ "$(declare -p SSH_KEYS 2>/dev/null)" != declare\ -A* ]]; then
echo "Error: SSH_KEYS is not a valid associative array."
exit 1
fi
KEY_ID="$LOCAL_SERVER_NAME|$REMOTE_SERVER_NAME"
# Debug (safe to keep)
echo "DEBUG: KEY_ID=$KEY_ID"
echo "DEBUG: Available keys: ${!SSH_KEYS[@]}"
if [[ -n "${SSH_KEYS[$KEY_ID]}" ]]; then
SSH_KEY="${SSH_KEYS[$KEY_ID]}"
else