skillfed

mock-ssh-server

Mock SSH server for testing purposes

mock-ssh-server v0.9.1 229.9K downloads/30d#9,120 on PyPI57
Permissive license MIT Active released

What it is and what it does

mock-ssh-server is a testing utility that spins up a lightweight SSH server in Python without needing OpenSSH installed. It wraps paramiko to provide a context manager you can use in test fixtures, letting you run real SSH and SFTP commands against a controlled server during unit or integration tests. You supply a dictionary of test users and their private key paths, then connect to the server using paramiko's client API just as you would to a real SSH host.

The package is designed for developers who need to test SSH-based tools, scripts, or libraries in isolation. Instead of mocking SSH calls or relying on external SSH infrastructure, you get a real SSH server running in your test process that you can tear down cleanly after each test.

Use it for:

  • Test SSH client code by connecting to a mock server in a pytest fixture without external SSH setup.
  • Verify SFTP file transfer logic by uploading and downloading files to a test server running in the same process.
  • Integration test SSH-based deployment or configuration management tools in CI/CD pipelines.
  • Validate SSH command execution and output parsing in tools that shell out over SSH.
  • Test multi-user SSH scenarios by configuring multiple test users with different keys in a single server instance.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Provides a Python context manager that runs an in-process SSH server for testing, built on paramiko, without requiring OpenSSH binaries.

Yes, if you need to test SSH or SFTP client code. The package has low install friction, is actively maintained, and carries no known vulnerabilities. The main caveat is that the latest release was 2021-09-13, so verify compatibility with your Python version and current paramiko versions before committing to it in a new project.

Install

mock-ssh-server on PyPI

pip

pip install mock-ssh-server

uv

uv add mock-ssh-server

poetry

poetry add mock-ssh-server

Installing mock-ssh-server

Before you install

Low friction: pure Python wheel with only paramiko and selectors2 as runtime dependencies. Actively maintained, with last commit on 2026-05-27.

License in practice

MIT license (permissive) — you can use, modify, and distribute this package freely in both open-source and commercial projects with minimal restrictions.

Quickstart

pip install mock-ssh-server

import mock_ssh_server

users = {"testuser": "/path/to/key"}
with mock_ssh_server.Server(users) as server:
    with server.client("testuser") as client:
        _, stdout, _ = client.exec_command("ls /")
        print(stdout.read())

Verify before relying

  • Whether the package works reliably with Python versions beyond 3.9 (classifiers list only through 3.9).
  • Current test coverage and whether all SSH/SFTP operations are fully supported for modern use cases.
  • Compatibility with current versions of paramiko and selectors2.

Package facts

License MIT (permissive)
Python support not specified
Install friction low — pure-Python wheel
Runtime dependencies 2 — paramiko, selectors2
Maintenance actively maintained — 1,796 days since the last release
Last repo commit
First released
Downloads 229,879/month — #9,120 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: mock_ssh_server-0.9.1-py3-none-any.whl

Development Status :: 4 - BetaEnvironment :: ConsoleIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: Python :: 2.7Programming Language :: Python :: 3.5Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Software Development :: Testing

Tags

ssh server testingmock ssh serverssh testing fixtureparamiko test serverssh client testingsftp testingssh integration tests
ssh-testingpytest-fixturesftp

More Testing packages