Skip to main content

Mock SSH server for testing purposes

Project description

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

Project details


Download files

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

Source Distribution

mock-ssh-server-0.8.1.tar.gz (11.6 kB view details)

Uploaded Source

Built Distribution

mock_ssh_server-0.8.1-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

File details

Details for the file mock-ssh-server-0.8.1.tar.gz.

File metadata

  • Download URL: mock-ssh-server-0.8.1.tar.gz
  • Upload date:
  • Size: 11.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.6.9

File hashes

Hashes for mock-ssh-server-0.8.1.tar.gz
Algorithm Hash digest
SHA256 00c592cbbf5e3c01939fe8dd0eb60f98fb6c4947e0c82cdd629eeec2d437c87c
MD5 973800952ddb7de2e3a4ab7870bc7510
BLAKE2b-256 88b09fc2c88df0132f8d34727cb566e3cfe5a88db104f19948515f4b708f85a0

See more details on using hashes here.

File details

Details for the file mock_ssh_server-0.8.1-py3-none-any.whl.

File metadata

  • Download URL: mock_ssh_server-0.8.1-py3-none-any.whl
  • Upload date:
  • Size: 12.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.6.9

File hashes

Hashes for mock_ssh_server-0.8.1-py3-none-any.whl
Algorithm Hash digest
SHA256 15a4ea71c9a638821a0e89b5cfde82d86fe4872e0ba2cf0c2ad5b276bf62000d
MD5 14d7845b72cba251bfd588178040a6d9
BLAKE2b-256 eeec2b376c308501ea08c0b06c04b35253dd6e66adfe4bca0b5c81d5a237e5ab

See more details on using hashes here.

Supported by

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