Skip to content

Hello World

Nicolas Couture edited this page Apr 19, 2026 · 1 revision

Hello World Mock

Creating a mock server with MockSSH is straightforward. This example demonstrates a minimal server that supports a single "exit" command.

Minimal Script (hello_mock.py)

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()

Running and Connecting

  1. Start the server:

    python hello_mock.py
  2. Connect via your system's SSH client:

    ssh admin@127.0.0.1 -p 2222
  3. Interact: When prompted for a password, enter password123. You will see the mock-shell> prompt. Type exit to disconnect.

Clone this wiki locally