-
Notifications
You must be signed in to change notification settings - Fork 0
Home
dharm pimsen edited this page Mar 17, 2024
·
10 revisions
PyserSSH is a library for remote control your code with ssh client. The aim is to provide a scriptable SSH server which can be made to behave like any SSH-enabled device.
This Server use port 2222 for default port
Install from pypi
pip install PyserSSH
Install from github
pip install git+https://github.com/damp11113/PyserSSH.git
import os
from PyserSSH import Server, Send, AccountManager
useraccount = AccountManager()
useraccount.add_account("admin", "") # create user without password
ssh = Server(useraccount)
@ssh.on_user("command")
def command(channel, command: str, client):
if command == "hello":
Send(channel, "world!")
ssh.run(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'private_key.pem'))
This example you can connect with ssh admin@localhost -p 2222
and press enter on login
If you input hello
the response is world
See server.py
I intend to leaked private key because that key i generated new. I recommend to generate new key if you want to use on your host because that key is for demo only.