ssh_run_command
Execute shell commands on remote SSH hosts and capture output with exit codes. Supports sudo, environment variables, and custom working directories.
Instructions
Execute a shell command on a remote SSH host and return the output.
The command runs in the login user's default shell. Both stdout and stderr are captured and returned. The exit code is included so you can detect failures.
Args: alias: Target host alias. command: Shell command to execute (e.g., 'ls -la /var/log', 'systemctl status nginx', 'df -h'). timeout: Maximum seconds to wait (default 60, max 3600). env: Optional extra environment variables dict for this command. cwd: Remote working directory. When set the effective invocation becomes 'cd && '. Use absolute POSIX paths (e.g. '/var/www/html'). State is NOT persisted between calls. sudo_password: When set, the command runs via sudo. The password is never echoed back in output. response_format: 'markdown' (default, human-readable) or 'json'.
Returns: Command output (stdout + stderr) with exit code.
Examples: - Inspect disk usage: command='df -h' - Check a service: command='systemctl status nginx' - Tail logs: command='tail -n 50 /var/log/syslog' - Install a package: command='sudo apt-get install -y htop'
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| alias | Yes | ||
| command | Yes | ||
| timeout | No | ||
| env | No | ||
| cwd | No | ||
| sudo_password | No | ||
| response_format | No | markdown |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |