From 801fbd359d521dd6dc959ac15b7edeaa84f55999 Mon Sep 17 00:00:00 2001 From: Youssef Date: Thu, 3 Sep 2026 14:05:44 +0200 Subject: [PATCH] fix(ci): add UserKnownHostsFile=/dev/null and target gitea_ci_key to fix read-only ssh error --- .gitea/workflows/ci-prod.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/ci-prod.yml b/.gitea/workflows/ci-prod.yml index e17753e..20ea5cd 100644 --- a/.gitea/workflows/ci-prod.yml +++ b/.gitea/workflows/ci-prod.yml @@ -135,7 +135,15 @@ jobs: -e DEST_DIR="${DEST_DIR}" \ alpine:latest sh -c ' apk add --no-cache openssh-client rsync && \ - SSH_CMD="ssh -p ${PORT} -o StrictHostKeyChecking=no -o ConnectTimeout=15" && \ + KEY_ARG="" && \ + if [ -f /root/.ssh/gitea_ci_key ]; then \ + KEY_ARG="-i /root/.ssh/gitea_ci_key -o IdentitiesOnly=yes" ; \ + elif [ -f /root/.ssh/id_ed25519 ]; then \ + KEY_ARG="-i /root/.ssh/id_ed25519 -o IdentitiesOnly=yes" ; \ + elif [ -f /root/.ssh/id_rsa ]; then \ + KEY_ARG="-i /root/.ssh/id_rsa -o IdentitiesOnly=yes" ; \ + fi && \ + SSH_CMD="ssh -p ${PORT} ${KEY_ARG} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o ConnectTimeout=15" && \ echo "Deploying backup script and .env to DB Server (${TARGET_USER}@${TARGET_HOST}:${DEST_DIR})..." && \ $SSH_CMD "${TARGET_USER}@${TARGET_HOST}" "mkdir -p ${DEST_DIR}/scripts" && \ rsync -avz -e "$SSH_CMD" scripts/backup_db.sh "${TARGET_USER}@${TARGET_HOST}:${DEST_DIR}/scripts/" && \