fix: Force bash for SSH commands and suppress known_hosts warnings

- Add UserKnownHostsFile=/dev/null to prevent write errors on read-only .ssh
- Wrap all SSH commands with 'bash -c' for fish shell compatibility on remote

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
kappa
2026-02-07 23:12:18 +09:00
parent 98d2054d6c
commit 98e55ab1a5

View File

@@ -21,6 +21,7 @@ def _ssh_base_cmd() -> list[str]:
cmd = [
"ssh",
"-o", "StrictHostKeyChecking=no",
"-o", "UserKnownHostsFile=/dev/null",
"-o", "BatchMode=yes",
"-o", "ConnectTimeout=10",
"-p", str(SSH_PORT),
@@ -45,7 +46,7 @@ def remote_exec(command: str, timeout: int = SUBPROCESS_TIMEOUT) -> subprocess.C
subprocess.TimeoutExpired: If command times out
OSError: If SSH command fails to execute
"""
ssh_cmd = _ssh_base_cmd() + [command]
ssh_cmd = _ssh_base_cmd() + ["bash", "-c", command]
logger.debug("SSH exec: %s", command)
return subprocess.run(
ssh_cmd,
@@ -89,11 +90,10 @@ def remote_write_file(path: str, content: str) -> None:
Raises:
IOError: If write fails
"""
# Escape content for shell, use heredoc via stdin
ssh_cmd = _ssh_base_cmd()
# Atomic write: write to temp file, then rename
# Atomic write: write to temp file, then rename (force bash for compatibility)
remote_script = f"tmpf=$(mktemp {path}.tmp.XXXXXX) && cat > \"$tmpf\" && mv \"$tmpf\" {path}"
ssh_cmd.append(remote_script)
ssh_cmd.extend(["bash", "-c", remote_script])
logger.debug("SSH write: %s (%d bytes)", path, len(content))
result = subprocess.run(