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:
@@ -21,6 +21,7 @@ def _ssh_base_cmd() -> list[str]:
|
|||||||
cmd = [
|
cmd = [
|
||||||
"ssh",
|
"ssh",
|
||||||
"-o", "StrictHostKeyChecking=no",
|
"-o", "StrictHostKeyChecking=no",
|
||||||
|
"-o", "UserKnownHostsFile=/dev/null",
|
||||||
"-o", "BatchMode=yes",
|
"-o", "BatchMode=yes",
|
||||||
"-o", "ConnectTimeout=10",
|
"-o", "ConnectTimeout=10",
|
||||||
"-p", str(SSH_PORT),
|
"-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
|
subprocess.TimeoutExpired: If command times out
|
||||||
OSError: If SSH command fails to execute
|
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)
|
logger.debug("SSH exec: %s", command)
|
||||||
return subprocess.run(
|
return subprocess.run(
|
||||||
ssh_cmd,
|
ssh_cmd,
|
||||||
@@ -89,11 +90,10 @@ def remote_write_file(path: str, content: str) -> None:
|
|||||||
Raises:
|
Raises:
|
||||||
IOError: If write fails
|
IOError: If write fails
|
||||||
"""
|
"""
|
||||||
# Escape content for shell, use heredoc via stdin
|
|
||||||
ssh_cmd = _ssh_base_cmd()
|
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}"
|
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))
|
logger.debug("SSH write: %s (%d bytes)", path, len(content))
|
||||||
result = subprocess.run(
|
result = subprocess.run(
|
||||||
|
|||||||
Reference in New Issue
Block a user