
rhost
io.github.starfield17/rhost
Operate SSH Linux hosts over OpenSSH with recoverable runs, CAS file edits, and tmux sessions.
Documentation
rhost
Operate SSH-reachable Linux hosts from coding agents or scripts over standard OpenSSH.
rhost gives coding agents (Claude Code, Codex, or any stdio MCP client) and CLI scripts local-like execution semantics over your existing OpenSSH setup: foreground commands, recoverable background Runs, compare-and-swap file edits with rollback, and persistent tmux sessions—backed by one capability layer (CLI, schema-v8 JSON, and stdio MCP), with zero remote daemon and zero remote Python.
Claude Code / Codex / CLI / JSON (schema v8)
-> local OpenSSH (~/.ssh/config, ssh-agent, host keys, ControlMaster)
-> standalone C99 remote helper / tmux (recoverable Runs, CAS files, PTYs)
Why it's built this way
- OpenSSH instead of a custom SSH stack: Reuses
~/.ssh/config(aliases,ProxyJump,Match),ssh-agent, strict host-key verification, andControlMaster(ControlPersist=15m).rhostnever prompts for passwords, stores keys, or weakens host-key checks. - Survives disconnects and timeouts: Long-running jobs (
run start/rhost_run) execute under a standalone remote monitor with durable state under~/.local/state/rhost/v5(RHOST_REMOTE_STATE). Client timeouts or cancellations only stop local observation, and uncertain submissions deduplicate safely. - Bounded reads and safe file edits: File reads default to 8 KiB (
8192bytes) and Run/session log previews default to 4 KiB (4096bytes) with byte cursors (run watchfollows both streams) instead of flooding agent context. File replacements verify whole-file SHA-256 and record changesets for rollback (fs undo). - C99 helper instead of remote Python: Native file operations and recoverable Runs run through a standalone C99 binary (
helper/) cached privately at~/.cache/rhost/helper/. Preparation reuses a valid cache, compiles with an existing remote C99cc, or uploads a SHA-256-verified static Linux musl release binary (linux-x86_64,linux-aarch64), with no remote daemon and no package installs.
Install
Release binaries (macOS and Linux on amd64/arm64; requires local Python 3.11+, verifies SHA-256 before atomic replacement):
curl -fsSL https://raw.githubusercontent.com/starfield17/rhost/main/scripts/install.sh | bash
Use RHOST_VERSION to pin a release or RHOST_INSTALL_DIR to set the binary directory (defaults to ~/.local/bin, or an existing writable standalone rhost / Homebrew bin on macOS PATH). Run rehash or hash -r if an open shell cached a prior path.
From source (Rust 1.88.0+):
git clone https://github.com/starfield17/rhost.git
cd rhost
make build-release
install -m 755 target/release/rhost ~/.local/bin/rhost
make build-release runs cargo build --locked --release --bin rhost and stamps commit/build date into rhost version --json; make build builds the debug binary.
Connect an agent
Ensure noninteractive OpenSSH works first using an SSH alias, user@example-host, or hostname:
claude mcp add --transport stdio --scope local rhost -- rhost mcp
codex mcp add rhost -- rhost mcp
Generic stdio clients launch rhost with ["mcp"] (use an absolute path if a GUI client's PATH differs). Filter advertised tools at startup with rhost mcp --tools runs,files (default all; groups: runs, files, sessions, diagnostics).
Install the optional Agent Skill to load workflow and recovery guidance on demand:
npx skills add starfield17/rhost --skill rhost
plugin.json and .codex-plugin/plugin.json package skills/rhost/SKILL.md; they require the rhost CLI separately and do not register MCP. See MCP setup guide for client configuration, SSH_AUTH_SOCK, tool schemas, and cancellation semantics.
Quick examples
# Inspect host readiness (read-only) and read or patch a remote file with CAS protection
rhost brief gpu --json
rhost fs read gpu ~/work/project/config.toml --json
rhost fs patch gpu ~/work/project/config.toml --from - --json <<'EOF'
{"edits":[{"old_text":"batch_size = 16","new_text":"batch_size = 32"}]}
EOF
# Start a recoverable background Run and follow output across reconnects
rhost run start gpu --cwd '~/work/project' --command 'cargo test --locked' --json
rhost run watch gpu <run_id> --json
# Device Mode: push a local tree, run remotely, and pull artifacts without remote Git
rhost push ./project gpu --name demo
rhost run --at demo --hosts gpu --command 'make test'
rhost pull gpu output.json ./output.json --at demo
# Foreground command execution
rhost exec gpu --cwd '~/work/project' --command 'uname -a'
Single closed JSON requests (schema_version: 8, matching MCP structuredContent) work via stdin:
rhost request --from - <<'EOF'
{"schema_version":8,"operation":"fs.read","host":"gpu","params":{"path":"~/work/project/config.toml","max_bytes":4096}}
EOF
Operations and references
| Need | Interface | Reference |
|---|---|---|
| Bounded read/search, CAS edit, changesets | CLI, JSON, MCP rhost_read, rhost_find, rhost_edit | FILES.md |
| Recoverable work surviving CLI/MCP exit | CLI, JSON, MCP rhost_run | RUNS.md |
Stateful shell, REPL, debugger (tmux) | CLI, JSON, MCP rhost_term | SESSIONS.md |
| Foreground command, transfers, Device Mode, tunnels | CLI (exec, fs put/get/sync/mirror, push/pull, tunnel) | CLI.md |
| Host brief, aliases, diagnosis, MCP setup | CLI, JSON, MCP | MCP.md |
Helper cache/build policy, error.code recovery, safety | Policy & recovery tables | NATIVE.md, RECOVERY.md, SAFETY.md |
- Diagnosis vs. preparation:
rhost doctorprobes shell tools and resolvedcommand -vpaths (ok:truemeans the probe completed; inspectcapabilities). Nativefs.*andrun.*prepare the C99 helper automatically;rhost helper preparereturnsgeneration,remote_time_unix, and helper identity explicitly (rhost helper statusreads an existing namespace without creating one). - Remote requirements:
execanddoctorrequire/bin/sh,bash,ps,base64, and eithersetsidor Perl withPOSIX::setsid.sessionrequiresbash,tmux,flock(session attachis refused withUSAGE_ERROR); resumable/checksum transfers requirersync; nativefs.*andrun.*require only POSIXshutilities to bootstrap the C99 helper (no remote Python ortmux). - Schema and boundaries: Public JSON uses schema v8 (
v7.1.0+); branch onerror.codeanderror.recovery, not prose. See state discovery and retention forrun.list,fs.changeset.list,state.list,state.usage, andstate.prune.rhostdoes not manage SSH credentials, system packages, Git branches/worktrees, or job scheduling.
Docs, schemas, and verification
- Architecture and ownership
- Contract ledger
- Request schema v8 and Result schema v8
- Agent skill
- Glama MCP server listing
- Contributor rules and Maintenance policy
make test-smoke # offline Rust black-box suite (no network)
make check # fmt, clippy, unit/contract/structure/portability/packaging checks
# Manual pre-release real-SSH suites (require an explicit target)
RHOST_TEST_HOST=<user>@<host> RHOST_BIN=./target/debug/rhost make test-live
RHOST_TEST_HOST=<user>@<host> RHOST_BIN=./target/debug/rhost make test-live-session
RHOST_TEST_HOST=<user>@<host> RHOST_BIN=./target/debug/rhost make test-live-all
make test-smoke and make check run offline; CI builds the shipping Linux helpers and verifies them against disposable strict-host-key sshd fixtures. Real-host test-live* and test-live-helper runs are optional manual pre-release verification; see Maintenance policy.
License
rhost is released under the BSD 3-Clause License.
https://github.com/starfield17/rhost/releases/download/v7.1.2/rhost_7.1.2.mcpb# mcpb: https://github.com/starfield17/rhost/releases/download/v7.1.2/rhost_7.1.2.mcpb