Skip to main content

mock-ssh-server - An SSH server for testing purposes

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.8.0

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.8.0
File Size Uploaded
mock-ssh-server-0.8.0.tar.gz 11.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mock-ssh-server 0.8.0
File Interpreter ABI Platform
mock_ssh_server-0.8.0-py2-none-any.whl Python 2 none any Details

Total release size: 24.3 kB

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

Download URL mock-ssh-server-0.8.0.tar.gz
Size 11.6 kB
Tags Source
SHA-256 checksum
How to use checksums
35d3bff1b272878d6dfcdccd7b435199cc31c7e1590eccc1345eaadbca3eb78a
BLAKE2b-256 checksum
How to use checksums
ee62ec4426c8d663cd7c8ca127bbc49a1e4803971f4a6ca337d576551092c4b2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/2.7.10

Release files / mock_ssh_server-0.8.0-py2-none-any.whl

Download URL mock_ssh_server-0.8.0-py2-none-any.whl
Size 12.7 kB
Tags Python 2
SHA-256 checksum
How to use checksums
5bdaacb697dc19bd75c65e8f52c784c419468898756022d1397d4f7821f32bd7
BLAKE2b-256 checksum
How to use checksums
a008b90cb4f7f4ccb61ce3b6429536564de426b2d7bf39ba270357b62f6a81e1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/2.7.10

Release history Release notifications | RSS feed

0.9.1

2 release files

0.9.0

2 release files

0.8.2

2 release files

0.8.1

2 release files

This release

0.8.0 This release

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