Skip to main content

EZSSH

An Ergonomic and Lightweight SSH Library.

Installation

pip install ezssh

Quick Start

Username and password authentication to a remote server.

from ezssh import SSHRunner, Command, BatchPolicy

# As of v0.0.9, SSHRunner will auto-add on new host. Disable for added security.
with SSHRunner(
    host="10.0.0.5",
    username="ubuntu",
    password="secret", # password as null will attempt pubkey using current user keystore in ~/.ssh
    missing_host_key_policy='autoadd'
) as runner:

    result = runner.run("uname -a")
    print(result.stdout)

    batch = runner.run_batch(
        [
            "whoami",
            Command("systemctl is-active ssh", sudo=True, name="ssh_status"),
        ],
        policy=BatchPolicy(stop_on_failure=False),
    )

    for r in batch.results:
        print(r.command.name, r.exit_status)

SSH Key filename/Directory Support

EzSSH Supports key-based authentication. Specify a key file or directory of keys to use, like so:

from ezssh.client import SSHRunner

if __name__ == "__main__":
    # define a key file
    with SSHRunner('x.x.x.x', 'username', pkey_file='./keys/id_rsa') as client:
        # classify_keyfile(key_file='./keys/id_rsa')
        print(client.run('uname -a').stdout)

As of Version 0.1.2, EzSSH now supports key directories. This will authenticate against a server using all keys in the specified directory.

from ezssh.client import SSHRunner

if __name__ == "__main__":
    # define a directory of key files 
    with SSHRunner('x.x.x.x', 'username', keys_dir='./some/directory') as client:
        print(client.run('uname -a').stdout)

Batch Operations

batch processing of cli commands is also available. To execute a chain of prepared commands:

batch = runner.run_batch(
    [
        Command("mkdir -p /tmp/example"),
        Command("touch /tmp/example/file.txt"),
        Command("false", name="intentional_failure"),
        Command("echo still runs"),
    ],
    policy=BatchPolicy(stop_on_failure=False),
)
# Each returns an exit status, stdout/stderror, start/end and duration.

Authentication Behavior

Password auth uses password only, agent and key discovery are opt-in.

SSHRunner(
    host="example.com",
    username="user",
    password="secret",
    allow_agent=False,
    look_for_keys=False,
)

When to Use ezssh

Use ezssh if you need:

  • Programmatic SSH execution embedded in a Python application
  • Deterministic batch execution with structured results
  • Explicit authentication behavior
  • Lightweight automation without orchestration frameworks

Do not use ezssh if you need:

  • Configuration management
  • Long-lived agents
  • Inventory management
  • Declarative state convergence

How ezssh Compares

Tool ezssh Paramiko Fabric Ansible
Embedded in apps ✅ ⚠️ ⚠️ ❌
Best Effort Auth ✅ ⚠️ ❌ ❌
Batch semantics ✅ ❌ ⚠️ ✅
Explicit auth ✅ ❌ ❌ ⚠️
Minimal deps ✅ ✅ ❌ ❌
YAML required ❌ ❌ ❌ ✅

Metadata

Release files for ezssh 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ezssh 0.2.1
File Size Uploaded Provenance Actions
ezssh-0.2.1.tar.gz 13.6 kB Without provenance Details for ezssh-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ezssh 0.2.1
File Interpreter ABI Platform Actions
ezssh-0.2.1-py3-none-any.whl Python 3 none any Details for ezssh-0.2.1-py3-none-any.whl

Total release size: 27.0 kB

Release files / ezssh-0.2.1.tar.gz

Download URL ezssh-0.2.1.tar.gz
Size 13.6 kB
Tags Source
SHA-256 checksum
How to use checksums
d87861fee11de9567157dd31195cc71dcb6f29104ed58e6a78f545fc8c1d28cc
BLAKE2b-256 checksum
How to use checksums
6d91e10509e784cbe3e39a8fd2a18a9a6e280c17cec00e7fdf36db0ae80f5edd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.2

Release files / ezssh-0.2.1-py3-none-any.whl

Download URL ezssh-0.2.1-py3-none-any.whl
Size 13.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6ec4aaeed60c19907a3dee61f89eea6311faf6d2fa4ea74c2441e21a3fd60f4a
BLAKE2b-256 checksum
How to use checksums
10944926a4bb1e990463a8455042364413b4afaf53d357f3231de7dfe779ce30
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.2

Security for ezssh 0.2.1

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page