ssh_exec
Run shell commands on a remote host over SSH and return exit code, stdout, and stderr for non-interactive tasks with optional working directory, stdin, sudo, and timeout.
Instructions
Run a shell command on a remote host and return exit_code, stdout and stderr.
The command runs non-interactively in the remote user's shell (no TTY; stdin is closed unless
stdin is given), so use non-interactive flags such as apt-get -y. Each call is a fresh shell:
use cwd or cd x && ... instead of relying on a previous cd. On timeout the command
and its children are killed. For anything slower than a few minutes, or that must keep running
(servers, builds, training, tail -f), use ssh_job_start instead.
Args:
target: device name, ~/.ssh/config alias, or [user@]host[:port].
command: shell command line (multi-line scripts are fine).
timeout: seconds before the command is killed (default from config, 60s).
cwd: directory to run the command in.
stdin: text fed to the command's standard input (e.g. file content for tee file).
sudo: run as root. Uses the device's sudo_password if configured, else sudo -n.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"target": "<target>",
"command": "<command>"
},
"name": "ssh_exec"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cwd | No | ||
| sudo | No | ||
| stdin | No | ||
| target | Yes | ||
| command | Yes | ||
| timeout | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||