diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index c2eb9cd..4812d0b 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -92,7 +92,21 @@ jobs: chmod 600 ~/.ssh/id_deploy ssh-keyscan -T 5 $DEPLOY_HOST >> ~/.ssh/known_hosts 2>/dev/null || true - SSH_CMD="ssh -i ~/.ssh/id_deploy -o StrictHostKeyChecking=no -o ConnectTimeout=10 root@$DEPLOY_HOST" + SSH_CMD="ssh -i ~/.ssh/id_deploy -o StrictHostKeyChecking=no -o ConnectTimeout=10 -o ServerAliveInterval=15 root@$DEPLOY_HOST" + + # SSH 연결 테스트 (최대 3회, kex_exchange 거부 대응) + for attempt in 1 2 3; do + echo "SSH connectivity test $attempt/3..." + if $SSH_CMD echo "SSH OK"; then + break + fi + if [ "$attempt" -eq 3 ]; then + echo "ERROR: SSH connection failed after 3 attempts" + exit 1 + fi + echo "SSH failed, retrying in 10s..." + sleep 10 + done $SSH_CMD bash -s << 'RESTART' DEPLOY_DIR=/devdata/services/kcg/backend