Skip to main content

Async local/remote file ops over SSH (scp/rsync) with robust defaults and Python bindings

Project description

async_server_ops (robust 0.3.0)

Async, robust file operations:

  • Local (tokio fs)
  • Remote via OpenSSH (scp) with optional rsync (auto-fallback if missing)
  • Non-interactive defaults (BatchMode, ConnectTimeout, ServerAlive*)
  • Correct scp port flag (-P), separate from ssh -p
  • Optional password mode via sshpass -e (set password), otherwise key-based

Build (Rust)

cargo build

Build (Python)

pip install maturin
maturin develop -F python        # dev install into venv
# or build wheels:
maturin build -F python --release --manylinux 2014

Python usage

import asyncio
from async_server_ops import ServerManagerPy as ServerManager, PyRemoteConfig as RemoteConfig

async def main():
    cfg = RemoteConfig(
        host="192.168.222.61",
        user="administrator",
        key_path="~/.ssh/id_ed25519",
        port=22,
        prefer_rsync=False,             # rsync optional; scp is default path
        # password=None,                # set if you really must use passwords (requires sshpass on client)
        # robust non-interactive defaults already applied; you can add more:
        ssh_extra_args=[
            "-o","IdentitiesOnly=yes",
            "-o","BatchMode=yes",
            "-o","ConnectTimeout=8",
            "-o","ServerAliveInterval=5","-o","ServerAliveCountMax=2",
        ],
    )
    m = ServerManager.remote(cfg)

    # Remote file to local
    rem = "/home/administrator/FoodIpadStorage/temp/dksl_c4db8429.pdf"
    await m.download_file(rem, "file.pdf")
    print("downloaded")

    # Upload back
    await m.create_dir_all("/tmp/ops_demo")
    await m.upload_file("file.pdf", "/tmp/ops_demo/file.pdf")
    print("uploaded")

asyncio.run(main())

Preflight check

ok = await m.preflight()  # checks ssh/scp locally, connectivity, and remote rsync presence
print("preflight:", ok)

Notes

  • Install rsync on both sides if you set prefer_rsync=True. Otherwise scp is used.
  • If you use password auth, install sshpass on the client (the lib passes it via env SSHPASS safely).
  • For production, load your key into ssh-agent to avoid prompts.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

async_server_ops-0.3.0-cp38-abi3-win_amd64.whl (64.1 kB view details)

Uploaded CPython 3.8+Windows x86-64

File details

Details for the file async_server_ops-0.3.0-cp38-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for async_server_ops-0.3.0-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 8583a978ffcc38a2a6093a559d7aed38d4c54e64892ef0f9f6cee350d66e5c38
MD5 f89d0bad32c13a9df2d2080ce2b97b61
BLAKE2b-256 3eb535a778187b6b721dde87f677e6b4197f233bb136b20b804ac5fe9991cb9c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page