ssh_exec
Execute shell commands on a remote host via SSH, with options for stdin, working directory, environment, timeouts, and background jobs.
Instructions
Execute an intentional shell command on the remote host. Supports stdin, cwd, env, custom output limit, and acceptable exit codes. Set background=true to run a command detached and get a job_id; stdin is not allowed for background jobs. Use ssh_exec_result to poll/wait and ssh_exec_kill to stop or clean up.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cwd | No | Working directory on the remote host. | |
| env | No | Extra environment variables for the command. | |
| stdin | No | Text to write to the command's stdin. Not allowed when background=true. | |
| target | Yes | SSH target in the form user@host[:port]. Uses the local SSH config and keys. | |
| command | Yes | ||
| ok_codes | No | Exit codes to treat as success in addition to 0. | |
| background | No | Run the command detached and return a job_id instead of waiting for completion. | |
| timeout_ms | No | Timeout for non-background executions. | |
| max_output_bytes | No | Maximum stdout/stderr bytes to capture for non-background executions. |