Mock SSH Server
Simple SSH Mock Server for E2E testing purposes, e.g. with Testcontainers.
Installation
Python
pip install ssh-mock
ssh-mock
Docker
See docker-compose.yml or run:
docker run --rm -p 5050:5050 -v ./commands.yml:/usr/src/app/commands.yml ghcr.io/danielhabenicht/mock-ssh:0.2.2
ssh localhost -p 5050
exec echo Hello World!
YAML Configuration
version: "3.7"
commands:
- command: echo hello
stdout: "Hello World!"
returncode: 0
- command: interface.*
stdout: ""
- command: exec echo.*
stdout_template: "{{command[9:]|trim|trim('''')|trim('\"')}}"
returncode: 0
- command: enable
stdout: "Password"
modify_host: HOST#
returncode: 0
- 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!