diff options
author | Jesse Luehrs <doy@tozt.net> | 2014-09-14 20:37:02 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2014-09-14 20:37:02 -0400 |
commit | 4fd854da5a59da2478a40277b43c26686e25469b (patch) | |
tree | 00cc68963be3ce9c0d9040ea9502075e3e500ca0 /ssh.py | |
parent | fc45d0b642b482f47638ca9b0f8fe69c8c9006b3 (diff) | |
download | python-termcast-server-4fd854da5a59da2478a40277b43c26686e25469b.tar.gz python-termcast-server-4fd854da5a59da2478a40277b43c26686e25469b.zip |
split the termcast and ssh handling out into separate files
Diffstat (limited to 'ssh.py')
-rw-r--r-- | ssh.py | 47 |
1 files changed, 47 insertions, 0 deletions
@@ -0,0 +1,47 @@ +import paramiko +import time + +class Handler(object): + def __init__(self, sock, connections): + self.sock = sock + self.connections = connections + self.which + + def show(self): + pass + +class Connection(object): + def __init__(self, client, connection_id): + self.transport = paramiko.Transport(client) + self.transport.add_server_key(paramiko.RSAKey(filename='test_rsa.key')) + + def run(self, termcast_connections): + self.transport.start_server(server=Server()) + chan = self.transport.accept(None) + + if len(termcast_connections) > 0: + chan.send(termcast_connections.values().__iter__().__next__().handler.get_term()) + else: + chan.send("no data for doy\r\n") + + time.sleep(5) + chan.close() + +class Server(paramiko.ServerInterface): + def check_channel_request(self, kind, chanid): + return paramiko.OPEN_SUCCEEDED + + def check_channel_pty_request(self, channel, term, width, height, pixelwidth, pixelheight, modes): + return True + + def check_channel_shell_request(self, channel): + return True + + def check_auth_password(self, username, password): + if password == "blah": + return paramiko.AUTH_SUCCESSFUL + return paramiko.AUTH_FAILED + + def get_allowed_auths(self, username): + return "password" + |