mirror of https://github.com/jumpserver/jumpserver
Update terminal
parent
5e33c2dc6b
commit
2c64b78487
|
@ -124,13 +124,42 @@ class SSHServerInterface(paramiko.ServerInterface):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def check_channel_window_change_request(self, channel, width, height, pixelwidth, pixelheight):
|
def check_channel_window_change_request(self, channel, width, height, pixelwidth, pixelheight):
|
||||||
logger.info('Change window size %s * %s' % (width, height))
|
|
||||||
logger.info('Change length %s ' % len(self.__class__.channel_pools))
|
|
||||||
for channel in self.__class__.channel_pools:
|
|
||||||
channel.send("Hello world")
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
class BackendServer:
|
||||||
|
def __init__(self, host, port, username):
|
||||||
|
self.host = host
|
||||||
|
self.port = port
|
||||||
|
self.username = username
|
||||||
|
self.ssh = None
|
||||||
|
self.channel = None
|
||||||
|
|
||||||
|
def connect(self, term='xterm', width=80, height=24):
|
||||||
|
self.ssh = ssh = paramiko.SSHClient()
|
||||||
|
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||||
|
ssh.connect(hostname=self.host, port=self.port, username=self.username, password=self.host_password,
|
||||||
|
pkey=self.host_private_key, look_for_keys=False, allow_agent=True, compress=True)
|
||||||
|
self.channel = channel = ssh.invoke_shell(term=term, width=width, height=height)
|
||||||
|
return channel
|
||||||
|
|
||||||
|
@property
|
||||||
|
def host_password(self):
|
||||||
|
return 'redhat'
|
||||||
|
|
||||||
|
@property
|
||||||
|
def host_private_key(self):
|
||||||
|
return 'redhat'
|
||||||
|
|
||||||
|
|
||||||
|
class Navigation:
|
||||||
|
def __init__(self, username):
|
||||||
|
self.username = username
|
||||||
|
|
||||||
|
def display(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class SSHServer:
|
class SSHServer:
|
||||||
def __init__(self, host='127.0.0.1', port=2200):
|
def __init__(self, host='127.0.0.1', port=2200):
|
||||||
self.host = host
|
self.host = host
|
||||||
|
@ -142,13 +171,14 @@ class SSHServer:
|
||||||
self.server_channel = None
|
self.server_channel = None
|
||||||
self.client_channel = None
|
self.client_channel = None
|
||||||
|
|
||||||
def connect(self):
|
def invoke_with_backend(self):
|
||||||
ssh = paramiko.SSHClient()
|
pass
|
||||||
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
||||||
ssh.connect(hostname='127.0.0.1', port=22, username='root', password='redhat')
|
def display_navigation(self):
|
||||||
self.server_ssh = ssh
|
pass
|
||||||
self.server_channel = channel = ssh.invoke_shell(term='xterm')
|
|
||||||
return channel
|
def make_client_channel(self):
|
||||||
|
pass
|
||||||
|
|
||||||
def handle_ssh_request(self, client, addr):
|
def handle_ssh_request(self, client, addr):
|
||||||
logger.info("Get connection from %(host)s:%(port)s" % {
|
logger.info("Get connection from %(host)s:%(port)s" % {
|
||||||
|
@ -173,6 +203,8 @@ class SSHServer:
|
||||||
return
|
return
|
||||||
|
|
||||||
self.client_channel = client_channel = transport.accept(20)
|
self.client_channel = client_channel = transport.accept(20)
|
||||||
|
# self.client_channel = client_channel = transport.open_session()
|
||||||
|
# client_channel.get_pty(term='xterm')
|
||||||
if client_channel is None:
|
if client_channel is None:
|
||||||
print('*** No channel.')
|
print('*** No channel.')
|
||||||
return
|
return
|
||||||
|
@ -219,9 +251,8 @@ class SSHServer:
|
||||||
# pass
|
# pass
|
||||||
|
|
||||||
except Exception:
|
except Exception:
|
||||||
client_channel.close()
|
|
||||||
server_channel.close()
|
|
||||||
logger.info('Close with server %s from %s' % ('127.0.0.1', '127.0.0.1'))
|
logger.info('Close with server %s from %s' % ('127.0.0.1', '127.0.0.1'))
|
||||||
|
sys.exit(100)
|
||||||
|
|
||||||
def listen(self):
|
def listen(self):
|
||||||
self.sock.listen(5)
|
self.sock.listen(5)
|
||||||
|
|
Loading…
Reference in New Issue