ssh_execute
Execute shell commands on remote SSH servers. Auto-connect using environment variables or saved hosts, with background sessions for long-running tasks.
Instructions
Execute a command on a remote server. If session_id is omitted, auto-connects using environment variables. Supports background execution for long-running tasks (auto-detected or manual). Use session_type='screen' or 'tmux' for persistent sessions that survive SSH disconnect.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| host | No | SSH server hostname or IP. Alternative to session_id/name, can override hosts.json entry. | |
| name | No | Use a pre-configured host from hosts.json by name. Alternative to session_id. | |
| port | No | SSH port (used with host). | |
| wait | No | Wait for background task to complete. | |
| command | Yes | Shell command to execute on the remote server (required). | |
| timeout | No | Command timeout in seconds. Default 120s. For long tasks (docker pull, pg_basebackup), set higher or use background=true. | |
| workdir | No | Working directory for background tasks. | /tmp |
| log_file | No | Log file path for background task output. | /tmp/background_task.log |
| password | No | SSH password (used with host). | |
| use_sudo | No | Wrap command with sudo -S using sudo_password from ssh_connect. Password is passed via stdin, not visible in process list. | |
| username | No | SSH username (used with host). | |
| background | No | Run in background for long-running tasks. Auto-detected if not specified. | |
| session_id | No | Session ID from ssh_connect. If omitted, connects via name/host/env vars. | |
| session_type | No | Background session type: nohup (default), screen, or tmux (persistent). | nohup |
| wait_timeout | No | Max wait time in seconds when wait=True. | |
| confirm_dangerous | No | Bypass security validation for known-dangerous commands (e.g. rm -rf /path). Use with caution — only for operations you explicitly intend to perform. | |
| backup_before_delete | No | For recursive deletion commands (rm -r/rf), explicitly choose whether to backup targets before deleting. Set true to backup to /tmp/ssh_mcp_backup_<timestamp>/ then delete; set false to delete directly. Required when a recursive deletion is detected. |