remote-exec-0.1.0 is not a library.
rexec — Remote Code Execution + Folder Sync
A simple CLI tool to sync local folders and execute commands on remote hosts over SSH, designed to survive SSH disconnections.
Features
- Folder sync: rsync local directory to remote before execution
- Remote execution: commands run via
nohup, surviving SSH disconnects - Log following: streams remote output back to local terminal with offset tracking
- Auto-reconnect: exponential backoff reconnection on SSH disconnect
- Dependency check:
initcommand checks and auto-installs remote deps - SSH config: resolves host aliases from
~/.ssh/config - Authentication: SSH agent → identity file → default keys
Install
Usage
# Check and install remote dependencies (run once per host)
# Sync a folder and run a command
# Run a command without syncing
# Use with ssh config alias
# Direct user@host:port
How it works
- If
--syncis given, runsrsync -az --delete -e sshto sync the local folder to remote - Connects via russh (pure Rust SSH), authenticates via agent/keys
- Wraps the command in
nohup sh -c '...' > /tmp/rexec_<pid>_<rand>.log 2>&1 & - Polls the remote log file, streaming new content to local stdout
- On SSH disconnect: exponential backoff retry (1s→30s, max 10), resumes from last offset
- On process completion: prints exit status
SSH Disconnection Behavior
- Remote process continues running via
nohup(not killed when SSH drops) - Local CLI auto-reconnects with exponential backoff
- Log output resumes from last byte offset — no data lost
- If reconnection fails after 10 retries, prints remote log file path and exits
- The log file persists at
/tmp/rexec_<pid>_<rand>.logon the remote
init Command
Checks if rsync, sh, nohup exist on the remote host. If missing, auto-detects the package manager (apt-get/yum/dnf/apk/pacman) and installs them.
Build
# Binary at target/release/rexec
Dependencies
russh— pure Rust SSH clientssh2-config— parse ~/.ssh/configrsync(system) — required for folder sync (local + remote)