From 98e55ab1a5841cc4df4b14fd2238c9f6b9f706cc Mon Sep 17 00:00:00 2001 From: kappa Date: Sat, 7 Feb 2026 23:12:18 +0900 Subject: [PATCH] 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 --- haproxy_mcp/ssh_ops.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/haproxy_mcp/ssh_ops.py b/haproxy_mcp/ssh_ops.py index a8f66ec..5b41e53 100644 --- a/haproxy_mcp/ssh_ops.py +++ b/haproxy_mcp/ssh_ops.py @@ -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(