Agent-friendly SSH CLI and skill for real remote operations over Paramiko.
ai-ssh is built for AI agents that need to connect to Linux hosts, run commands, inspect services, transfer files, and make safe remote changes using structured JSON results instead of brittle plain-text shell parsing.
- Test SSH connectivity with
connect - Run non-interactive commands with
exec - Run privileged commands with
sudo - Upload and download files with
uploadanddownload - Read and write remote text files with
read,write, andwrite-b64 - Run local scripts remotely with
exec-local-script - Collect system information with
stat - Diagnose systemd services with
service-fail-summaryandservice-watch - Run long jobs with
job-runandjob-status - Watch network and process activity with
net-watchandproc-watch - Use persistent tmux-backed shells with
shell-open,shell-send, andshell-close
Typical SSH automation for agents is fragile for three reasons:
- Local shell quoting breaks before the command ever reaches SSH
- Plain stdout parsing is inconsistent across commands and environments
- Multi-step remote workflows need state, ordering, and structured results
ai-ssh addresses those issues by:
- returning JSON from every subcommand
- preferring high-level operations over raw
sshandscp - providing safer transport options like
--cmd-file,exec-local-script, andwrite-b64 - making long-running tasks and service diagnostics explicit
Use the simplest safe path.
- Use
connectfirst for new credentials - Use
execfor short, read-only inspection commands - Use
--cmd-fileinstead of inline--cmdfor anything non-trivial on Windows PowerShell - Use
exec-local-scriptwhen the task is naturally a script - Use
uploadfor complex JSON, YAML, shell scripts, and multiline content - Use
job-runfor long-running installs, downloads, builds, and migrations - Use
service-fail-summaryandservice-watchfor systemd troubleshooting
Dependent remote actions must be run sequentially.
Do not parallelize steps like:
write -> readupload -> execjob-run -> job-statusshell-open -> shell-send -> shell-close
Parse the JSON from the earlier step first, confirm success, then continue.
Inline commands are the main source of avoidable failures on Windows.
Avoid inline --cmd when the command contains:
$;or&&- braces
- nested quotes
- multiple file paths
awkorsed
Prefer:
--cmd-fileexec-local-scriptuploadwrite-b64
python scripts/cli.py connect --host 10.0.0.10 --user root --password secret
python scripts/cli.py exec --host 10.0.0.10 --user root --password secret --cmd hostname
python scripts/cli.py job-run --host 10.0.0.10 --user root --password secret --cmd-file .\install.sh --log /tmp/install.log --exit-file /tmp/install.exitExample job-run result:
{
"success": true,
"started": true,
"job_id": "...",
"job_ref": "job-abc123def456",
"status": "running",
"log": "/tmp/install.log",
"exit_file": "/tmp/install.exit"
}SKILL.md: full skill instructions for agent usescripts/cli.py: main CLI entrypointscripts/*.py: SSH, SFTP, systemd, job, tmux, and utility modules
The project is designed around real agent usage rather than theoretical SSH examples. It has been exercised against real remote hosts for:
- connectivity
- read-only inspection
- remote file read and write
- PowerShell quoting fallback paths
- background jobs
- systemd diagnostics
- tmux-backed persistent shell flows
BSD 2-Clause. See LICENSE.