Mocks an SSH Server
Project description
Mock SSH Server
Simple SSH Mock Server for E2E testing purposes, e.g. with Testcontainers.
Installation
Python
pip install ssh-mock
# Create commands.yml first
# Start Mock
ssh-mock
Docker
See docker-compose.yml or run:
# Create commands.yml first
# Run Mock Server:
docker run --rm -p 5050:5050 -v ./commands.yml:/usr/src/app/commands.yml ghcr.io/danielhabenicht/mock-ssh:0.2.2
# Try it out
ssh localhost -p 5050
exec echo Hello World!
YAML Configuration
version: "3.7"
commands:
# Simple command
- command: echo hello
stdout: "Hello World!"
returncode: 0
# Command matching regex
- command: interface.*
stdout: ""
# Return values from command via JINJA template
- command: exec echo.*
stdout_template: "{{command[9:]|trim|trim('''')|trim('\"')}}"
returncode: 0
# Modify the Hostname
- command: enable
stdout: "Password"
modify_host: HOST#
returncode: 0
# Use multiple lines
- command: show users
stdout: " Line User Host(s) Idle Location\n* 1 vty 0 rootuser idle 00:00:00\n example.test.de\n\n Interface User Mode Idle Peer Address\n\n"
returncode: 0
- command: show interfaces description
stdout: |
Interface Status Protocol Description
Vl1 up up
Vl308 up up
Gi1/0/1 up up Access Port
Gi1/0/12 down down Access Port
Gi1/1/1 down down
Gi1/1/2 down down
Te1/1/3 down down
Te1/1/4 up up
Thanks
This was initally a fork of https://github.com/d1618033/fake-ssh. Thanks David for your work!
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
ssh_mock-0.3.1.tar.gz
(8.9 kB
view details)
Built Distribution
File details
Details for the file ssh_mock-0.3.1.tar.gz
.
File metadata
- Download URL: ssh_mock-0.3.1.tar.gz
- Upload date:
- Size: 8.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.10.14 Linux/6.5.0-1022-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 20d75d0cc5f59f3d2c9c8432af43d5db247060255e4380b4a625c04b0b9b550a |
|
MD5 | d17e7880dabb192680270192e3f4b249 |
|
BLAKE2b-256 | 28480b51b645c4d211e44a0f57699e95afe06231ef515d7199ad55ec4c7535af |
File details
Details for the file ssh_mock-0.3.1-py3-none-any.whl
.
File metadata
- Download URL: ssh_mock-0.3.1-py3-none-any.whl
- Upload date:
- Size: 9.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.10.14 Linux/6.5.0-1022-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9517a06db876a030280edab191eb91d194d5cb89caf43f4787ef1f9fc0778e62 |
|
MD5 | 670a91f65c72fd451a64b9599324417c |
|
BLAKE2b-256 | 6e46857cbd1e14f0b31d924023f5c32f636a7ae1fe27739acef4cfd106fc9b14 |