mock-ssh-server
Mock SSH server for testing purposes
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-serveruv
uv add mock-ssh-serverpoetry
poetry add mock-ssh-serverInstalling 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
Tags
More Testing packages
Pluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
virtualenvvirtualenv creates isolated Python environments…
permissive · top 100 on PyPI
coverageCoverage.py measures which lines of Python code…
permissive · top 1,000 on PyPI
pytest-asynciopytest-asyncio is a pytest plugin that enables…
permissive · top 1,000 on PyPI
pytest-json-ctrfA pytest plugin that generates test reports in…
permissive · top 1,000 on PyPI
paramikoParamiko is a pure-Python SSH protocol library…
copyleft · top 1,000 on PyPI
mocksftpProvides an in-process SFTP server for testing…
permissive · top 15,000 on PyPI
sftpserverProvides a simple single-threaded SFTP server…
permissive · top 15,000 on PyPI
pytest-sftpserverA pytest plugin that provides a fixture for…
permissive · top 5,000 on PyPI
fs.sshfsfs.sshfs provides a PyFilesystem2 interface to…
copyleft · top 15,000 on PyPI
sftprettyA Python3 wrapper around paramiko that…
permissive · top 15,000 on PyPI
proxmoxerProxmoxer is a Python wrapper for the Proxmox…
permissive · top 15,000 on PyPI
paramiko-expectParamiko Expect adds expect-like pattern…
permissive · top 15,000 on PyPI
pysftppysftp provides a high-level Python interface…
permissive · top 5,000 on PyPI
sshuttlesshuttle creates a transparent proxy that…
copyleft · top 15,000 on PyPI