{"id":13937295,"url":"https://github.com/ncouture/MockSSH","last_synced_at":"2025-07-19T23:31:25.039Z","repository":{"id":6229965,"uuid":"7461545","full_name":"ncouture/MockSSH","owner":"ncouture","description":"Mock an SSH server and define all commands it supports (Python, Twisted)","archived":false,"fork":false,"pushed_at":"2023-12-19T20:45:05.000Z","size":82,"stargazers_count":125,"open_issues_count":9,"forks_count":23,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-11-18T10:34:44.716Z","etag":null,"topics":["dsl","emulator","hylang","mock","python","shell","ssh","ssh-server","twisted"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ncouture.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2013-01-05T23:51:38.000Z","updated_at":"2024-09-21T11:49:36.000Z","dependencies_parsed_at":"2024-01-03T04:02:44.040Z","dependency_job_id":null,"html_url":"https://github.com/ncouture/MockSSH","commit_stats":{"total_commits":67,"total_committers":4,"mean_commits":16.75,"dds":0.05970149253731338,"last_synced_commit":"0e2a40a9afc1668d21981fbb173a2685e1fe76db"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ncouture%2FMockSSH","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ncouture%2FMockSSH/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ncouture%2FMockSSH/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ncouture%2FMockSSH/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ncouture","download_url":"https://codeload.github.com/ncouture/MockSSH/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226693903,"owners_count":17667757,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dsl","emulator","hylang","mock","python","shell","ssh","ssh-server","twisted"],"created_at":"2024-08-07T23:03:28.443Z","updated_at":"2024-11-27T05:31:04.191Z","avatar_url":"https://github.com/ncouture.png","language":"Python","readme":"MockSSH\n=======\n\nMock an SSH server and all commands it supports.\n\n\nPurpose\n-------\nThis project was developed to emulate operating systems\nbehind SSH servers in order to test task automation without\nhaving access to the real servers.\n\nThere has been user interest in using MockSSH to perform\nend-to-end unit tests against SSH servers and as such a\nthreaded version of MockSSH server is available as of\nversion 1.4 (thanks to Claudio Mignanti).\n\nInstallation\n------------\nMockSSH depends on libraries that do not support Python 3k.\n```shell\nmkvirtualenv -p `which python2` mocksshenv\npip install mockssh\n```\n\nMockSSH in Python\n-----------------\nMockSSH aims to be as easy to use as possible.\n\nRefer to the mock_cisco.py and mock_F5.py in the examples/\ndirectory for an overview on how to use it.\n\n\nMockSSH in LISP\n---------------\nEfforts were invested in simplifying the use of MockSSH\nwith [HyLang](http://hylang.org/).\n\nAs a result a DSL is released with this project and\nresides in the *mocksshy/* directory.\n\nUsing the DSL will allow you to use MockSSH by writing\nsomething that is closer to a configuration file than\na program.\n\nFor comparison, here are two MockSSH servers\nimplementations providing the same functionality:\n\n\n*Python*\n```python\nimport MockSSH\n\ndef passwd_change_protocol_prompt(instance):\n    instance.protocol.prompt = \"hostname #\"\n    instance.protocol.password_input = False\n\ndef passwd_write_password_to_transport(instance):\n    instance.writeln(\"MockSSH: password is %s\" % instance.valid_password)\n\ncommand_passwd = MockSSH.PromptingCommand(\n    name='passwd',\n    password='1234',\n    prompt=\"Password: \",\n    success_callbacks=[passwd_change_protocol_prompt],\n    failure_callbacks=[passwd_write_password_to_transport])\n\nusers = {'admin': '1234'}\n\ncommands = [command_passwd]\n\nMockSSH.runServer(commands,\n                  prompt=\"hostname\u003e\",\n                  interface='127.0.0.1',\n                  port=2222,\n                  **users)\n```\n\n*HyLang*\n```clojure\n(import MockSSH)\n(require mocksshy.language)\n\n\n(mock-ssh :users {\"testuser\" \"1234\"}\n          :host \"127.0.0.1\"\n          :port 2222\n          :prompt \"hostname\u003e\"\n          :commands [\n  (command :name \"passwd\"\n           :type \"prompt\"\n           :output \"Password: \"\n           :required-input \"1234\"\n           :on-success [\"prompt\" \"hostname#\"]\n           :on-failure [\"write\" \"Pass is 1234...\"]))\n```\n\n\nUnit Testing with MockSSH\n-------------------------\nAs shown from the unit tests in the tests/ directory, it is possible to use\na threaded MockSSH server to perform end-to-end unit tests against mocked\nSSH services.\n\nNote that this may not be the right approach depending on your use case as only\none Twisted reactor can run at the same time and reactors cannot be restarted.\n\nCredits\n-------\nMockSSH is derived from [kippo](https://github.com/desaster/kippo/), an SSH honeypot.\n","funding_links":[],"categories":["Honeypots","Python"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fncouture%2FMockSSH","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fncouture%2FMockSSH","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fncouture%2FMockSSH/lists"}