Lightweight SSH toolkit with optional MCP(stdio) JSON-RPC adapter
Project description
SSHOC
English | 简体中文
A lightweight, config-driven SSH toolkit (CLI + optional MCP stdio adapter).
- CLI:
sshoc(list/run/upload/download/hostkey/..., plus prefix modesshoc <profile>: <command...>) - MCP (stdio):
sshoc-mcp(line-delimited JSON-RPC, exposesssh.*tools to MCP clients) - Dependency:
paramiko(SSH/SFTP)
Goal: strict, predictable, easy to embed (especially for automation / AI workflows).
Quick start (pip users)
- Install:
python -m pip install -U sshoc
- Initialize config (recommended: per-user config directory):
# Password auth (recommended: store password in an env var)
sshoc init demo --ssh "ssh -p 22 user@host" --password-env SSHOC_DEMO_PASSWORD
# Or: key auth
sshoc init demo --ssh "ssh -p 22 user@host" --key-path ~/.ssh/id_ed25519
- Set the password env var (only needed for
password_env):
$env:SSHOC_DEMO_PASSWORD="your_password"
export SSHOC_DEMO_PASSWORD="your_password"
- First connection (known_hosts):
Default known_hosts_policy=strict. If the host key is not present in your local known_hosts, the first connection will fail. Recommended: write the host key first (optionally verify a trusted fingerprint):
sshoc hostkey ensure demo
# Strongly recommended (if you can get a trusted fingerprint from your provider/admin):
# sshoc hostkey ensure demo --expected-fingerprint "SHA256:..."
- Run a command:
sshoc demo: uname -a
# Or
sshoc run demo --cmd "uname -a"
Installation (development)
Install from source (recommended: create a venv in this directory):
cd "SSH_Operation_Component (MCP)"
python -m venv .venv
.venv\\Scripts\\activate
python -m pip install -U pip
python -m pip install -e .
Configuration
Where is the config file (and which one is in use)?
sshoc config path
Practical tip: pin the config path with SSHOC_CONFIG
$env:SSHOC_CONFIG="C:\\path\\to\\sshoc.config.json"
export SSHOC_CONFIG="/path/to/sshoc.config.json"
Key fields (cheatsheet)
servers.<profile>: profile name (recommended:A-Za-z0-9_-)servers.<profile>.ssh_command: common formssh -p <port> user@hostauth.type:password:passwordorpassword_envkey:private_key_path(optionalprivate_key_passphrase_env)
known_hosts_policy:strict: default; unknown host keys fail fast (safer)accept_new: auto-write toknown_hosts_pathon first connect (TOFU)
known_hosts_path: OpenSSHknown_hostspath (template default:~/.ssh/known_hosts)default_shell: defaultbash -lc(set tonullif the remote has no bash)
CLI
Common commands
sshoc list
sshoc demo: "ls -la /root"
sshoc run demo --cmd "python -V"
sshoc upload demo --local ./local.txt --remote /tmp/local.txt --overwrite
sshoc download demo --remote /tmp/local.txt --local ./downloaded.txt --overwrite
Host key / known_hosts
These commands print JSON (friendly for scripts/CI/automation).
# Scan the remote host key (no auth)
sshoc hostkey scan demo
# Check whether the host is present in known_hosts
sshoc hostkey is-known demo
# Scan + write into known_hosts (optional fingerprint verification)
sshoc hostkey ensure demo
sshoc hostkey ensure demo --expected-fingerprint "SHA256:..."
# Manually add a key (if you already have key_type + base64)
sshoc hostkey add demo --key-type ssh-ed25519 --public-key-base64 "<BASE64>"
# Precise removal: remove one key type, or remove all key types for the host
sshoc hostkey remove demo --key-type ssh-ed25519
sshoc hostkey remove demo --all-types
MCP (stdio) server
Start:
sshoc-mcp
Tools:
ssh.list_profilesssh.scan_host_keyssh.is_known_hostssh.add_known_hostssh.ensure_known_hostssh.runssh.uploadssh.download
Generic stdio config blueprint (for MCP clients)
Different MCP clients may use different config formats, but the essentials are usually: command / args / env / cwd. Below is a generic blueprint (field names are for reference—adapt to your client):
{
"mcpServers": {
"sshoc": {
"command": "sshoc-mcp",
"args": ["--config", "<ABS_CONFIG_PATH>"],
"env": {
"SSHOC_DEMO_PASSWORD": "your_password",
"SSHOC_DEBUG": "0"
},
"cwd": "<OPTIONAL_WORKDIR>"
}
}
}
// Examples for <ABS_CONFIG_PATH>:
// - macOS/Linux: /path/to/sshoc.config.json
// - Windows: C:\\path\\to\\sshoc.config.json
Security notes (strongly recommended)
- Never commit plaintext passwords; prefer
password_env accept_newis TOFU (trust on first use); safer: verify with--expected-fingerprint- This tool effectively gives automation/AI a remote execution entry point—use it only in environments you trust
License
Apache-2.0 (see LICENSE)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sshoc-0.1.3.tar.gz.
File metadata
- Download URL: sshoc-0.1.3.tar.gz
- Upload date:
- Size: 32.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6b84d193b155c34a754f96cbcdb31bf0eccf2310d5ee13ea34ed7eea960f3686
|
|
| MD5 |
b1ba67ae8b675fe5d940875aecd83eac
|
|
| BLAKE2b-256 |
1691c46860a524d9479f484e1e81fd9d64857de4483915c5a110e5eb9f22e6ec
|
File details
Details for the file sshoc-0.1.3-py3-none-any.whl.
File metadata
- Download URL: sshoc-0.1.3-py3-none-any.whl
- Upload date:
- Size: 33.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
91f9b5b3cd8dc6a7181176e3177bc0b709e414776282b7ae0bc956c1bde4ad1c
|
|
| MD5 |
03dd566029ab92f09ed79f87b84563ef
|
|
| BLAKE2b-256 |
ee231a2e5e4c437ea1e2f8ffb7d90c543b8a589c7fd885583bf36be851b0ee58
|