Skip to main content

mock-ssh-server packs a Python context manager that implements an SSH server for testing purposes. It is built on top of paramiko, so it does not need OpenSSH binaries to be installed.

Sample usage

As a py.test fixture:

import os

from pytest import yield_fixture

import mockssh


@yield_fixture()
def server():
    users = {
        "sample-user": "/path/to/user-private-key",
    }
    with mockssh.Server(users) as s:
        yield s


def test_ssh_session(server):
    for uid in server.users:
        with server.client(uid) as c:
            _, stdout, _ = c.exec_command("ls /")
            assert stdout.read()

def test_sftp_session(server):
    for uid in server.users:
        target_dir = tempfile.mkdtemp()
        target_fname = os.path.join(target_dir, "foo")
        assert not os.access(target_fname, os.F_OK)

        with server.client(uid) as c:
            sftp = c.open_sftp()
            sftp.put(__file__, target_fname, confirm=True)
            assert os.access(target_fname, os.F_OK)
https://travis-ci.org/carletes/mock-ssh-server.svg

Metadata

Release files for mock-ssh-server 0.9.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 mock-ssh-server 0.9.1
File Size Uploaded
mock-ssh-server-0.9.1.tar.gz 12.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mock-ssh-server 0.9.1
File Interpreter ABI Platform
mock_ssh_server-0.9.1-py3-none-any.whl Python 3 none any Details

Total release size: 27.2 kB

Release files / mock-ssh-server-0.9.1.tar.gz

Download URL mock-ssh-server-0.9.1.tar.gz
Size 12.8 kB
Tags Source
SHA-256 checksum
How to use checksums
720f18440dad67b0b4b23fac2a54e3bd020245876836b16a8dfedec6a6ea8598
BLAKE2b-256 checksum
How to use checksums
ff454b88dab25108c1d061a6fe8e0a0eb4b4c4b925d65b4b6eef55cdf0e249ab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.6

Release files / mock_ssh_server-0.9.1-py3-none-any.whl

Download URL mock_ssh_server-0.9.1-py3-none-any.whl
Size 14.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0ec42bfb8ba11c9249ce47b80acd01de3e9ee109b7a8d7161a37bd3924806a27
BLAKE2b-256 checksum
How to use checksums
258e10b75e759440b221d8fa0f9a39c8d3a73d573e9ca1b7317c573c97d5d34b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.6

Release history Release notifications | RSS feed

This release

0.9.1 This release

2 release files

0.9.0

2 release files

0.8.2

2 release files

0.8.1

2 release files

0.8.0

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.0

1 release file

0.2.0

1 release file

0.1.0

1 release file

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