rmote¶
rmote runs Python functions through SSH, docker exec, kubectl exec, a
local Python process, or another bidirectional stream connected to Python.
See Transports for the common model, including prepared nc relays.
Built-in tools manage files, commands, packages, services, and users. You can
also define your own tools and return Python values from them.
Install rmote locally with Python 3.11 or newer:
python -m pip install rmote
The target needs Python 3.11 or newer but no rmote installation. rmote sends tool code over the connection when it is first used. Package and service tools require their system commands and sufficient permissions on the target.
To operate without an agent, rmote runs standard python3 -qui on the target:
-q(quiet): suppresses Python’s startup banner and copyright notices.-u(unbuffered): forces unbuffered stdout/stderr streams for instant packet delivery.-i(interactive): reads and executes statements from stdin even without a TTY.
A free-threaded interpreter works on both sides. rmote has no compiled extension, and it guards the state it shares between threads with its own locks. The tests cover 3.13t and 3.14t on Linux and macOS.
Start with a Deployment¶
Follow the Quickstart to deploy a Redis cache in a disposable Docker container. You will install a package, render a systemd unit, start the service, and check that it works. The deployment code also works over SSH by replacing the connector.
Choose a Guide¶
Task |
Guide |
|---|---|
Connect through SSH, containers, local Python or another byte stream |
|
Write a remote operation and return Python data |
|
Explore a host from a Python console |
|
Collect and cache host state |
|
Apply an operation to several hosts |
|
Synchronize file contents in either direction |
|
Synchronize files or trees from the command line |
|
Render a configuration file |
|
Write and transfer a custom template filter |
|
Find a built-in operation |
|
Configure synchronous connections and deadlines |
|
Use connections from an async application |
|
Understand code transfer, state, and cancellation |
Use rmote.sync.Connection for synchronous scripts and rmote.protocol.Protocol
for async applications. Both clients call the same tools. Use rmote only with
trusted hosts and tool code: the target executes transferred Python, and the
client unpickles returned data.
User Guide
- Quickstart
- Install rmote
- Prepare a Disposable Host
- Connect and Run a Command
- Create an Administrator
- Grant and Check sudo Access
- Install Redis
- Render a systemd Service
- Write the Unit and Start the Service
- Check an Unchanged Rerun
- Write a Tool for Your Application
- Use the Same Deployment over SSH
- Clean Up and Continue
- Transports
- TLS over a transport
- Writing Tools
- Python REPL
- File and directory synchronization
- Interactive shell
- SSH clients over rmote
- Work with Multiple Hosts
- Templating
- Why rmote has its own template engine
- Using the engine
- Context and missing values
- Expressions
- Filters
- Conditions and Loops
- Assignments
- Whitespace and Comments
- Compilation and intermediate representation
- The
render_templateHelper - The
RenderTemplateTool - Diagnose template errors
- Measuring performance
- Writing template filters
- Concepts
Releases