1.9 KiB
1.9 KiB
Server Event
To handle the event can use on_user()
decorator
connect
Called when user connected to server and authenticated
@ssh.on_user("connect")
def connect(client):
# do something
connectsftp
Called when user connected to server and authenticated with sftp
@ssh.on_user("connectsftp")
def connectsftp(client):
# do something
auth (only usexternalauth=True in Server())
Called when user press enter to server and authenticating
ssh = Server(usexternalauth=True)
@ssh.on_user("auth")
def auth(data):
# do something
return
data
{
"username": ...,
"password": ...,
}
return True/False
connectpty
Called when user connected to server and authenticated with pty request (terminal info)
@ssh.on_user("connectpty")
def connectpty(client, data):
# do something
data
{
"term": ...,
"width": ...,
"height": ...,
"pixelwidth": ...,
"pixelheight": ...,
"modes": ...
}
resized
Called when user resized terminal
@ssh.on_user("resized")
def resized(client, data):
# do something
data
{
"width": ...,
"height": ...,
"pixelwidth": ...,
"pixelheight": ...
}
command
Called when user entered command
@ssh.on_user("command")
def command(client, command):
# do something
type
Called press key (no ansi)
@ssh.on_user("type")
def type(client, key):
# do something
rawtype
Called press key
@ssh.on_user("rawtype")
def rawtype(client, key):
# do something
error
Called when inside command event error
@ssh.on_user("error")
def error(client, error):
# do something
disconnected
Called when user is exited (safe exit)
@ssh.on_user("disconnected")
def disconnected(client):
# do something
timeout
Called when user is timeout (on inputsystem only)
@ssh.on_user("timeout")
def timeout(client):
# do something