-
Notifications
You must be signed in to change notification settings - Fork 25
Hello World
Nicolas Couture edited this page Apr 19, 2026
·
1 revision
Creating a mock server with MockSSH is straightforward. This example demonstrates a minimal server that supports a single "exit" command.
import MockSSH
# Define the built-in exit command
from MockSSH import command_exit
def main():
# Define users and their passwords
users = {'admin': 'password123'}
# Supported commands
commands = [command_exit]
# Start the server
MockSSH.runServer(
commands,
prompt="mock-shell> ",
interface='127.0.0.1',
port=2222,
**users
)
if __name__ == "__main__":
main()-
Start the server:
python hello_mock.py
-
Connect via your system's SSH client:
ssh admin@127.0.0.1 -p 2222
-
Interact: When prompted for a password, enter
password123. You will see themock-shell>prompt. Typeexitto disconnect.