def chk_close_sftp(self): while 1: time.sleep(10) for hostid, elfinder in self.elfinder_sftps.items(): if not cache.get('elfinder_%s' % hostid): # import ipdb; ipdb.set_trace() self.elfinder_sftps.pop(hostid).close()
def chk_close_ssh(self): while 1: time.sleep(10) for sshlog_id, proxy_ssh in self.sshs.items(): if not cache.get('proxy_ssh_%d' % sshlog_id): # import ipdb; ipdb.set_trace() proxy_ssh.chan_cli.send( u'\033[1;3;31m系统管理员已强制中止了您的终端连接\033[0m\r\n') self.sshs.pop(sshlog_id).chan_ser.transport.close()
def chk_close_ssh(self): while 1: time.sleep(10) for sshlog_id, proxy_ssh in self.sshs.items(): if not cache.get('proxy_ssh_%d' % sshlog_id): # import ipdb; ipdb.set_trace() if not proxy_ssh.closed: try: proxy_ssh.chan_cli.send( u'\033[1;3;31m系统管理员已强制中止了您的终端连接\033[0m\r\n') except: pass proxy_ssh.close() # 先关闭再从字典中移出 self.sshs.pop(sshlog_id)
def check_auth_password(self, http_user, password): # 验证密码 key = 'clissh_%s_%s' % (http_user, password) print(http_user, password) hostid = cache.get(key) if hostid: # ssh_client ===>> proxy_server 验证通过 if not self.ssh_args: self.set_ssh_args(hostid) self.http_user = http_user self.hostid = hostid # self.conn_ssh(hostid) return paramiko.AUTH_SUCCESSFUL return paramiko.AUTH_FAILED
def check_auth_password(self, username, password): # 验证密码 key = 'clissh_%s_%s' % (username, password) hostid = cache.get(key) if hostid: # ssh_client ===>> proxy_server 验证通过 if not self.ssh_args: self.set_ssh_args(hostid) # self.conn_ssh(hostid) try: self.sshlog = proxys.newlog(self, hostid, username) # 录像回放/强制结束终端 return paramiko.AUTH_SUCCESSFUL except: print('验证成功,但由于终端日志生成失败,为安全不通过登陆验证。') return paramiko.AUTH_FAILED