From e557a94ed0699cbac596c28973d199e287131a78 Mon Sep 17 00:00:00 2001 From: wangjia <809946525@qq.com> Date: Mon, 6 Jul 2026 15:05:44 +0800 Subject: [PATCH] =?UTF-8?q?fix(ci):=20lib-ssh=20=E5=8A=A0=20IdentitiesOnly?= =?UTF-8?q?+BatchMode(=E4=BF=AE=20Too=20many=20auth=20failures)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CI ssh 到 pangolin1 报 Too many authentication failures + 回落密码提示:ssh 把 容器默认/agent key 也一并递上,撞 MaxAuthTries。加 IdentitiesOnly=yes 只用 -i key, BatchMode=yes 纯非交互。影响 deploy-server / backup 等所有走 lib-ssh 的部署。 Co-Authored-By: Claude Opus 4.8 --- scripts/ci/lib-ssh.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/ci/lib-ssh.sh b/scripts/ci/lib-ssh.sh index fc7cb9f..86d1ea8 100755 --- a/scripts/ci/lib-ssh.sh +++ b/scripts/ci/lib-ssh.sh @@ -56,8 +56,12 @@ setup_ssh() { # abort the deploy. ssh-keyscan -p "${DEPLOY_PORT}" -H "${DEPLOY_HOST}" >> "${SSH_KNOWN_HOSTS_FILE}" 2>/dev/null || true - SSH="ssh -i ${SSH_KEY_FILE} -p ${DEPLOY_PORT} -o StrictHostKeyChecking=accept-new -o UserKnownHostsFile=${SSH_KNOWN_HOSTS_FILE}" - RSYNC_SSH="ssh -i ${SSH_KEY_FILE} -p ${DEPLOY_PORT} -o StrictHostKeyChecking=accept-new -o UserKnownHostsFile=${SSH_KNOWN_HOSTS_FILE}" + # IdentitiesOnly=yes:只用上面 -i 指定的 key,不把 agent/默认 key 也递上去 + # (否则会触发服务器 MaxAuthTries「Too many authentication failures」)。 + # BatchMode=yes:纯非交互,认证失败即退出,不回落到密码提示卡住。 + _ssh_opts="-i ${SSH_KEY_FILE} -p ${DEPLOY_PORT} -o IdentitiesOnly=yes -o BatchMode=yes -o StrictHostKeyChecking=accept-new -o UserKnownHostsFile=${SSH_KNOWN_HOSTS_FILE}" + SSH="ssh ${_ssh_opts}" + RSYNC_SSH="ssh ${_ssh_opts}" export SSH RSYNC_SSH SSH_KEY_FILE SSH_KNOWN_HOSTS_FILE DEPLOY_HOST DEPLOY_PORT echo "==> setup_ssh: key written to ${SSH_KEY_FILE}, known_hosts pinned (accept-new) for ${DEPLOY_HOST}:${DEPLOY_PORT}" }