fix(deploy): rsync SSH에 -i 키파일 명시 (macOS Keychain 우회)

macOS에서 rsync 서브프로세스는 Keychain 키를 자동 로드하지 못해
비밀번호 프롬프트로 fallback됨. -i ~/.ssh/id_rsa 명시로 해결.
- BatchMode=yes: 비밀번호 프롬프트 차단 (명확한 에러 반환)
- StrictHostKeyChecking=accept-new: 최초 연결 host key 자동 수락
- NAS_SSH_KEY 환경변수로 다른 키 파일 지정 가능

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-01 09:35:56 +09:00
parent b11d1c421d
commit 11e4f00ae6

View File

@@ -1,5 +1,6 @@
const { execSync } = require("child_process"); const { execSync } = require("child_process");
const fs = require("fs"); const fs = require("fs");
const os = require("os");
const path = require("path"); const path = require("path");
// Load .env.local from project root if present (persists NAS_SSH_TARGET etc.) // Load .env.local from project root if present (persists NAS_SSH_TARGET etc.)
@@ -55,7 +56,11 @@ if (isWin) {
process.exit(1); process.exit(1);
} }
const sshCmd = cleanPort ? `ssh -p ${cleanPort}` : "ssh"; // macOS Keychain은 서브프로세스(rsync)에서 SSH 키를 자동 로드하지 못함 → -i 명시
const keyFile = process.env.NAS_SSH_KEY || path.join(os.homedir(), ".ssh", "id_rsa");
const portOpt = cleanPort ? `-p ${cleanPort}` : "";
const sshCmd = `ssh ${portOpt} -i "${keyFile}" -o StrictHostKeyChecking=accept-new -o BatchMode=yes`.trim();
console.log(`Deploying via SSH → ${cleanTarget}:${cleanPath}`); console.log(`Deploying via SSH → ${cleanTarget}:${cleanPath}`);
console.log(`SSH command: ${sshCmd}`); console.log(`SSH command: ${sshCmd}`);
execSync( execSync(