A CLI-based SSH agent tool that maps ssh-mcp-server capabilities into remote operations callable by agents.
Remote exec · File upload · File download · Connection config · Command whitelist · Command blacklist · Agent Skill integration
AI One-Click Installation · Manual Installation · Configuration · Uninstall and Cleanup · License · Friendly Links
中文 | English
This project references the SSH operation design from classfang/ssh-mcp-server and rewrites it as an independent CLI. Thanks to the original project for the ideas and capability foundation.
- Free your hands and automate server operations
- Deploy code and update Docker deployments
- Configure nginx and certificates
- Do anything SSH can do
- List SSH server connections from local configuration
- Execute commands on a specified remote server
- Upload local files to a remote server with temporary files, resume, and retry
- Download files from a remote server to local
- Restrict executable commands through command allowlists and blocklists
Uploads are written to <remotePath>.part first, with resume metadata in <remotePath>.part.meta. After the temporary file size is verified, it is renamed to the final target path. If an upload is interrupted, running the same upload again resumes from the existing .part size when the local file metadata still matches.
For --no-cache uploads, use Ctrl+C to stop the current CLI process. In daemon mode, agentsshcli stop-daemon stops the connection-pool process, but it affects other tasks in the same daemon and is not a precise per-upload cancel operation.
Please read https://github.com/sleepinginsummer/agent-ssh-cli/blob/main/AI_INSTALL.md, follow the instructions to install the CLI, and add `SKILL.md`.
- Node.js
>= 18 - npm
>= 8 - Local network access to the target SSH server
- If private key authentication is used, the private key file must be readable by the current user
- Prebuilt platform packages support macOS arm64/x64, Linux x64/arm64, and Windows x64
- Install globally:
npm install -g agent-ssh-cli
agentsshcli --help- Import SKILL.md:
Open SKILL.md and add it to the agent.
Initialize the configuration. The format parameters are compatible with ssh-mcp-server:
mkdir -p ~/.agent-ssh-cliEdit ~/.agent-ssh-cli/config.json and fill in the real connection information. The default configuration file path can also be overridden with an environment variable:
You can change the configuration location with the following environment variable:
AGENT_SSH_CONFIG=/path/to/config.jsonThe configuration file is an array, and each item represents one server:
name: Connection name, must be uniquehost: SSH host addressusername: SSH usernamepassword/passwordRef/privateKey: Authentication method; keep exactly one authentication type among password, password reference, and private keyport: SSH port, defaults to22passphrase: Private key passphrase, only used withprivateKeysocksProxy: SOCKS5 proxy address, for examplesocks5://127.0.0.1:1080; the scheme can also be omitted as127.0.0.1:1080jumpHost: Jump host connection name, must reference anothernamein the config filepty: Whether to allocate a pseudo-terminal, defaults tofalse; it can also be enabled per command withexec --ptyallowedLocalPaths: Legacy-compatible field; local paths are not restricted nowcommandWhitelist: Command whitelist regular expression arraycommandBlacklist: Command blacklist regular expression array
commandWhitelist and commandBlacklist use JavaScript RegExp syntax, not POSIX regular expressions. Write whitespace as \\s; do not use [:space:].
See the full example in example.config.json. Store real connection information in ~/.agent-ssh-cli/config.json.
To reduce password leakage from configuration files, password authentication is passively encrypted the first time that server is used: after you write a plaintext password, the next exec, upload, or download for that server encrypts the password into secrets.json under the config directory, creates a local secret.key, then writes the config back with an empty password and a passwordRef. Later runs decrypt through passwordRef. To change the password, replace the empty password with the new plaintext password; the next connection overwrites the old encrypted value.
Reference configuration
[
{
"name": "password-server",
"host": "192.0.2.10",
"port": 22,
"username": "root",
"password": "",
"passwordRef": "agentsshcli:password-server",
"jumpHost": "jump-server",
"commandBlacklist": [
"(^|[;&|()\\s])rm(\\s|$)",
"(^|[;&|()\\s])shutdown(\\s|$)",
"(^|[;&|()\\s])reboot(\\s|$)"
]
},
{
"name": "jump-server",
"host": "198.51.100.20",
"port": 22,
"username": "ubuntu",
"privateKey": "/path/to/jump_key",
"passphrase": "******",
"socksProxy": "socks5://127.0.0.1:1080"
},
{
"name": "key-server",
"host": "198.51.100.10",
"port": 22,
"username": "deploy",
"privateKey": "/path/to/id_rsa",
"passphrase": "******",
"pty": false,
"allowedLocalPaths": [
"./tmp",
"./dist"
],
"commandWhitelist": [
"^pwd$",
"^ls(\\s|$)",
"^cat\\s+/var/log/app\\.log$"
],
"commandBlacklist": [
"(^|[;&|()\\s])rm(\\s|$)",
"(^|[;&|()\\s])shutdown(\\s|$)",
"(^|[;&|()\\s])reboot(\\s|$)"
]
}
]Test command
agentsshcli list
agentsshcli exec --no-cache password-server "pwd"
agentsshcli exec --pty password-server "tty"
agentsshcli exec password-server --command-file ./script.sh --timeout 60000Installation is complete.
Update to the latest version:
npm install -g agent-ssh-cli@latestRemove:
npm uninstall -g agent-ssh-cli
npm cache clean --force
# Delete the configuration file
rm -rf ~/.agent-ssh-cli