Enhance SSH connection attempts for IPv6

Add support for IPv6 loopback connection attempts in init.sh.
This commit is contained in:
247LIKE authored and GitHub committed 2025-12-16 16:34:47 +08:00
1 parent 00231364b9
commit dee80b0be7
1 file changed
+14
+14
View File
@@ -1713,6 +1713,20 @@ enhanced_ssh_test() {
success=1
break
fi
# 尝试 1: IPv4 回环 (主流情况)
if ssh -o BatchMode=yes -o ConnectTimeout=3 -o StrictHostKeyChecking=no \
-o UserKnownHostsFile=/dev/null -o GlobalKnownHostsFile=/dev/null \
-p "$port" "$user@127.0.0.1" "exit 0" >/dev/null 2>&1; then
success=1
break
fi
# 尝试 2: IPv6 回环 (针对纯 IPv6 环境的备选)
if ssh -o BatchMode=yes -o ConnectTimeout=3 -o StrictHostKeyChecking=no \
-o UserKnownHostsFile=/dev/null -o GlobalKnownHostsFile=/dev/null \
-p "$port" "$user@::1" "exit 0" >/dev/null 2>&1; then
success=1
break
fi
fi
attempts=$((attempts + 1))
[ "$attempts" -le "$max_attempts" ] && sleep 1