SSH directory synchronization library and CLI
Project description
SSHMirror
Sync a working directory with a remote server over SSH, inspect diffs before applying changes, and keep a lightweight local history for rollback-oriented workflows.
SSHMirror is both:
- a Python library you can import;
- a CLI you can run inside a project folder;
- a sync workflow that keeps local and remote changes inspectable.
It can also be used as a lightweight sync workflow for a shared project: multiple developers can make changes to the same remote-backed codebase and inspect differences before pulling or pushing updates.
Internet access is not required for SSHMirror itself. It only needs network access to the target SSH host or Docker host you are synchronizing with.
When you run sshmirror without arguments, it opens an interactive menu.
Depending on project state, the menu can include:
Create sshmirror.config.ymlCreate sshmirror.ignore.txtInitializationPull & PushStatusView current changesView version changesPull onlyStash changesRestore stashed changesForce pullDiscard all local changesDiscard selected filesDowngrade remote versionTest connectionExit
Why It Stands Out
- Preview first. Inspect current file changes and version-to-version diffs before syncing. 🔍
- Built for real SSH workflows. Passwords, SSH keys, passphrases, and ssh-agent fallback are supported. 🔐
- Keeps local state. SSHMirror stores version and migration metadata under
.sshmirror/. 🗂️ - Works as a library or a command-line tool. 🐍
- Useful for team workflows. Several developers can work on one project and sync changes through the same remote environment. 🤝
- Optional remote container restart after sync. 🐳
Install 🚀
pip install sshmirror
For local development:
pip install -e .
Quick Start ⚡
-
Create a config file:
sshmirror
On first interactive launch, SSHMirror can create
sshmirror.config.ymlfor you. -
Start from this minimal config:
host: '192.168.12.22' port: '50022' username: 'root' localdir: '.' remotedir: '/app' author: your-name
-
Check status or connect-test before syncing:
sshmirror --status sshmirror --test-connection
Example Configuration ⚙️
The full example lives in sshmirror.config.example.yml.
Supported auth patterns:
- password auth;
- private key auth;
- private key with passphrase;
- default SSH keys or ssh-agent when no key and no password are provided.
Example with optional container restart:
host: '192.168.12.22'
port: '50022'
username: 'root'
localdir: '.'
remotedir: '/app'
author: your-name
restart_container:
# Optional. If omitted, host/port/username are reused from the main SSH config.
# host: '192.168.12.22'
# port: '23322'
# username: user
sudo: true
container_name: testcontainer
restart_container connects to the Docker host where the container is running. If host, port, or username are not specified there, SSHMirror uses the main connection values.
CLI Commands 🧰
sshmirror --help
Main non-interactive flags:
--statusshow local and remote sync status;--current-diffinspect current local versus remote differences;--version-diffinspect changes between remote versions;--pullonly pull from remote;--stash-changesstash local changes before syncing;--restore-stashrestore previously stashed changes;--force-pulloverwrite local files from remote;--discarddiscard all local changes;--discard-files <paths...>discard only selected files;--downgradedowngrade remote version;--test-connectionvalidate SSH access to the remote host and configured Docker host.
Library Usage 📦
from sshmirror import SSHMirror, SSHMirrorConfig
mirror = SSHMirror(
config=SSHMirrorConfig(
host='127.0.0.1',
port=22,
username='root',
localdir='.',
remotedir='/app',
)
)
The public API is exported from sshmirror/init.py.
Project Layout
sshmirror/
sshmirror/ # importable package
tests/ # smoke tests
pyproject.toml # packaging metadata
sshmirror.config.example.yml
Development 🛠️
Run tests:
python -m unittest discover -s tests -p "test_*.py"
Build locally:
python -m build
Changelog
Latest release notes live in CHANGELOG.md.
Status
This repository is structured as a Python package with a CLI entry point. If you plan to publish to PyPI, keep package metadata, README, and license in sync with actual behavior.
Changelog
0.1.10
Changed
- Reworked
View version changesfor large version histories. - Replaced full-history rendering with interactive paginated browsing.
- Improved version timestamp presentation in interactive history views.
- Added colored tabular rendering and numeric shortcuts for version selection.
Added
- Added lazy remote paging for interactive version history browsing.
- Added author display in interactive version history views.
- Added a 50-character validation limit for version descriptions.
0.1.9
Fixed
- Fixed sudo password authentication for
restart_container.
Added
- Added step-by-step Docker host diagnostics for Docker host checks.
0.1.8
Fixed
- Fixed
restart_containerconnection handling.
Changed
- Removed deprecated
restart_container.usersupport and standardized onrestart_container.username.
Added
- Added startup validation for the full configuration, including
restart_containerconsistency checks.
0.1.7
Changed
- Optimized local and remote scanning so ignored directories are pruned instead of scanned and filtered after traversal.
0.1.6
Fixed
- Fixed postponed annotation evaluation and runtime annotation handling.
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 sshmirror-0.1.10.tar.gz.
File metadata
- Download URL: sshmirror-0.1.10.tar.gz
- Upload date:
- Size: 43.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6f6bc3e39fdd95a88cf8a6b39dfe86ec74ac9b3ed4719598d5c55684d32fb187
|
|
| MD5 |
31402a206df217a57873c719a668b67d
|
|
| BLAKE2b-256 |
761d608164d7bf285210bbe8d3685e1c2a9d9bc02ad97e707a71877f082982cc
|
File details
Details for the file sshmirror-0.1.10-py3-none-any.whl.
File metadata
- Download URL: sshmirror-0.1.10-py3-none-any.whl
- Upload date:
- Size: 38.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fa333f282a91bdafb477497a6e84a0115d9751fa12f17e536327243aa2589105
|
|
| MD5 |
47574533a1cb6080d9ad10a6a141a7c0
|
|
| BLAKE2b-256 |
ecd1043ce92a0ee2c9dfc238713e5694429d894ae7a965db44aee9af584c4d81
|