remote-cli
Shared SSH & Terminal CLI tool for AI Agent and Human Co-piloting.
remote-cli allows a human user to start an interactive SSH session (handling passwords, 2FA, bastion hosts, and SSH keys themselves) and share that session with an AI Agent via a unique session-id.
Key Features
- 🤝 Real-Time Human & Agent Co-piloting:
- The human sees everything the Agent does in their original terminal window in real-time.
- The human can continue typing and operating in the same session at any time.
- ⚡ Zero External Binary Dependencies:
- Pure Python + POSIX PTY (
pty.openpty,termios,tty). - No need to install
tmuxorscreenon local or remote servers.
- Pure Python + POSIX PTY (
- 🤖 First-Class AI Agent Support:
exec: Structured execution of shell commands with stdout capture and return codes.snapshot: In-memory 2D virtual terminal rendering (pyte) for clean screen capture (even for ncurses / curses / colored prompts).send: Keystrokes and control signals (Ctrl+C,Ctrl+D, confirmation answersy/n).logs: Fast access to recent scrollback history.
- 🔌 Seamless Background Daemon:
- Communicates via Unix Domain Sockets (
~/.remote-cli/remote-cli.sock). - Transparently auto-starts in the background on demand.
- Safely detach (
Ctrl+]) and re-attach (remote-cli attach <session-id>) anytime.
- Communicates via Unix Domain Sockets (
Installation & Setup
Using uv:
# Clone the repository
git clone https://github.com/your-username/remote-cli.git
cd remote-cli
# Install dependencies and create venv
uv sync
# Run directly via uv
uv run remote-cli --help
Quickstart & Workflow
1. Human Starts SSH Session
The user initiates the SSH connection to the remote machine. Once connected and authenticated, a Session ID is displayed:
uv run remote-cli ssh user@server.example.com
Output:
╭────────────────────── remote-cli SSH Session ──────────────────────╮
│ Session Created: s_7f8a9b2c │
│ Agent Command: remote-cli exec s_7f8a9b2c "<command>" │
│ Press Ctrl+] to detach from session at any time. │
╰────────────────────────────────────────────────────────────────────╯
user@server.example.com's password: ***
user@server:~$ _
Tip: You can also create local shell sessions for testing:
uv run remote-cli session create --name my-session -- /bin/bash
2. Share session-id with AI Agent
Simply tell your AI Agent:
"I have logged into the server. The session ID is
s_7f8a9b2c. Please check the disk space and restart Nginx."
The Agent can now execute commands on the remote server via remote-cli:
# Agent runs a command and captures return code and stdout
uv run remote-cli exec s_7f8a9b2c "df -h"
# Agent runs a command with JSON output
uv run remote-cli exec s_7f8a9b2c "systemctl status nginx" --json
# Agent inspects the current 2D screen state
uv run remote-cli snapshot s_7f8a9b2c
# Agent sends an interactive response (e.g. confirming a prompt)
uv run remote-cli send s_7f8a9b2c "y"
# Agent sends Ctrl+C to interrupt a long-running process
uv run remote-cli send s_7f8a9b2c --ctrl-c
# Agent transfers files or directories (like docker cp)
uv run remote-cli cp ./app.tar.gz s_7f8a9b2c:/opt/
uv run remote-cli cp s_7f8a9b2c:/var/log/nginx/error.log ./logs/
3. Human Observation & Intervention
While the Agent is executing commands or transferring files, the human user sees all command text and outputs scrolling in real time in their terminal window. If needed, the human can type commands directly into that same terminal window.
CLI Command Reference
| Command | Description |
|---|---|
remote-cli ssh [SSH_ARGS...] |
Start SSH session, print Session ID, and attach immediately |
remote-cli session create [-d] [-- <CMD...>] |
Create a new session (default: /bin/bash) |
remote-cli session list (or ls) |
List all active and recent sessions |
remote-cli session attach <ID> (or attach) |
Attach terminal in raw mode to existing session |
remote-cli session close <ID> |
Close and terminate a session |
remote-cli exec <ID> "<COMMAND>" |
Execute command in session, capture output & exit code |
remote-cli cp <SRC> <DEST> |
Transfer files/dirs between local & session (./file s_xxx:/remote/) |
remote-cli upload <ID> <LOCAL> <REMOTE> |
Upload local file or directory to remote session |
remote-cli download <ID> <REMOTE> <LOCAL> |
Download remote file or directory from session to local |
remote-cli send <ID> [TEXT] |
Send raw keystrokes or control keys (--ctrl-c, --ctrl-d) |
remote-cli snapshot <ID> |
Capture 2D terminal screen state (ANSI-rendered) |
remote-cli logs <ID> [-n LINES] |
View recent output scrollback logs |
remote-cli daemon start / stop / status |
Manage background daemon lifecycle |
Architecture
┌─────────────────────────┐ ┌───────────────────────────┐
│ Human User Terminal │ │ AI Agent / Script │
│ (Raw Mode) │ │ (remote-cli exec/snapshot)│
└────────────┬────────────┘ └─────────────┬─────────────┘
│ │
│ Attach (Stdin/Stdout stream) │ JSON Request/Response
▼ ▼
┌─────────────────────────────────────────────────────────────┐
│ remote-cli Daemon Process │
│ (Unix Domain Socket: ~/.remote-cli/remote-cli.sock) │
│ │
│ ┌────────────────────────────────────────────────────────┐ │
│ │ Session (e.g. s_7f8a9b2c) │ │
│ │ - Master/Slave PTY (`pty.openpty`) │ │
│ │ - SSH ControlMaster Socket (`~/.remote-cli/cm/*.sock`) │ │
│ │ - Pyte Virtual Terminal Screen (`pyte.HistoryScreen`) │ │
│ │ - Scrollback Ring Buffer │ │
│ │ - Exec Sentinel Detection Engine │ │
│ │ - Dual Transfer Engine: │ │
│ │ * Fast Path: Native OpenSSH ControlMaster SCP │ │
│ │ * Fallback: Universal In-Band Tar+Base64 Stream │ │
│ │ - Process: `ssh user@remote-server` (or local shell) │ │
│ └────────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────┘
Running Tests
uv run pytest -v
Release files for remote-cli 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| remote_cli-0.2.0.tar.gz | 1.9 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| remote_cli-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 2.0 MB
Release files / remote_cli-0.2.0.tar.gz
| Download URL | remote_cli-0.2.0.tar.gz |
|---|---|
| Size | 1.9 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
50d1514b6b8a35a6d740e7db57bb89c15e6a268db5b74efb7c2d60767df230df
|
|
BLAKE2b-256 checksum How to use checksums |
3c949fa48d036d713b023410f289b2b6432eebfc52ec769e54d3326605f24223
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 30, 2026.
Transparency logRelease files / remote_cli-0.2.0-py3-none-any.whl
| Download URL | remote_cli-0.2.0-py3-none-any.whl |
|---|---|
| Size | 25.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8ee61f26c2251cf5a562f5a4bae3854345fd44a63c6574742930d576e826220f
|
|
BLAKE2b-256 checksum How to use checksums |
4c898df8221a00328248b406fb4d905f8223f64b4f7388a5170b621bef19b860
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 30, 2026.
Transparency log