def process_request(self, client, addr):
rc = self.request_context({'REMOTE_ADDR': addr[0]})
rc.push()
logger.info("Get ssh request from %s" % request.environ['REMOTE_ADDR'])
transport = paramiko.Transport(client, gss_kex=False)
try:
transport.load_server_moduli()
except:
logger.warning('Failed to load moduli -- gex will be unsupported.')
raise
transport.add_server_key(SSHInterface.get_host_key())
# ?app??????????, ssh_interface ??ssh???????
ssh_interface = SSHInterface(self, rc)
try:
transport.start_server(server=ssh_interface)
except paramiko.SSHException:
logger.warning('SSH negotiation failed.')
sys.exit(1)
client_channel = transport.accept(20)
if client_channel is None:
logger.warning('No ssh channel get.')
sys.exit(1)
if request.method == 'shell':
logger.info('Client asked for a shell.')
InteractiveServer(self, ssh_interface.user_service, client_channel).run()
elif request.method == 'command':
client_channel.send(wr(warning('We are not support command now')))
client_channel.close()
sys.exit(2)
else:
client_channel.send(wr(warning('Not support the request method')))
client_channel.close()
sys.exit(2)
评论列表
文章目录