ssh_exec
Run shell commands on a remote server via SSH and get each command's exit code, stdout, and stderr.
Instructions
Runs one command or a list of them on a server, each with its own exit code, stdout and stderr. Work measured in minutes belongs in detach, not in a longer timeout. Reach for it last — files, logs, transfers, health and jobs each have a tool that batches the round trips and parses the answer.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cwd | No | Directory to start in, detached jobs included. Cannot be entered -> the command stops, it does not run elsewhere. | |
| sudo | No | Execute command(s) with sudo. Default: false | |
| detach | No | Background job on the server: returns an id at once, outlives this call, timeout does not apply. Follow with ssh_job_status / ssh_job_output, stop with ssh_job_kill. One command. With sudo the job runs as root and every later call follows it as root, provided the profile has a password or sudo needs none. Default: false | |
| command | Yes | One command, or a list: ["hostname", "whoami"]. Each runs in its own shell — no shared variable, no shared cd; cwd applies to all. A non-zero exit does not stop the list. | |
| profile | Yes | Machine name. | |
| timeout | No | Milliseconds, per command in a list, not for the whole list; default 30000. Work measured in minutes -> detach, not a bigger number. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| job_id | No | ||
| legend | No | What the words in this answer mean. A key names the field before the value — "state=limited", "jobs[].state=lost" — and only the values this answer actually used are listed. | |
| commands | No |