Skip to content

ssh_execute fails on Windows SSH hosts due to Linux timeout command wrapper #10

@kezarjg

Description

@kezarjg

Description

ssh_execute wraps all commands with the Linux timeout utility before sending
them to the remote host. When the remote host is Windows (OpenSSH for Windows),
timeout resolves to Windows' TIMEOUT.exe, which is a completely different
program, causing every command to fail.

Steps to Reproduce

  1. Configure a server pointing to a Windows host running OpenSSH:
    SSH_SERVER_MY_WIN_HOST=192.168.1.90, port 2222, user svc-ssh
  2. Run any command via ssh_execute:
    { "server": "my_win_host", "command": "whoami" }
    

Observed Behavior

Every command fails with:
ERROR: Invalid syntax. Default option is not allowed more than '1' time(s).
Type "TIMEOUT /?" for usage.

The server wraps the command as:
timeout 120 sh -c 'whoami'

Windows interprets timeout as TIMEOUT.exe (a user-input wait utility),
and sh does not exist on Windows.

Expected Behavior

Commands should execute successfully on Windows SSH hosts.

Suggested Fix

Skip the timeout + sh -c wrapper for Windows hosts. The SSH library's
built-in timeout (ssh.execCommand(command, { timeout: timeoutMs })) works
cross-platform. The existing rawCommand: true option already bypasses the
wrapper — a per-server config flag (e.g., SSH_SERVER_FOO_PLATFORM=windows)
could trigger this automatically.

Environment

  • mcp-ssh-manager: 3.1.3
  • Node.js: v24.13.1
  • MCP server host OS: Debian Linux 12 (bookworm)
  • Remote target OS: Windows 11 (build 26200.7840) with OpenSSH sshd
  • Claude Code: 2.1.45

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions