Skip to content

Commit

Permalink
Merge branch '7.x' of http://git.bt.cn:30000/root/linux-panel into 7.x
Browse files Browse the repository at this point in the history
  • Loading branch information
showpy committed Mar 31, 2022
2 parents 9659848 + 39eeaa4 commit dd6da1e
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions class/ssh_terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class ssh_terminal:
_debug_file = 'logs/terminal.log'
_s_code = None
_last_num = 0
_key_passwd = None

def connect(self):
'''
Expand Down Expand Up @@ -681,6 +682,8 @@ def set_attr(self,ssh_info):
self._pkey = ssh_info['pkey']
if 'password' in ssh_info:
self._pass = ssh_info['password']
if 'pkey_passwd' in ssh_info:
self._key_passwd = ssh_info['pkey_passwd']
try:
result = self.connect()
except Exception as ex:
Expand Down Expand Up @@ -822,6 +825,7 @@ def get_host_find(self,args):
host_info['username'] = info_tmp['username']
host_info['password'] = info_tmp['password']
host_info['pkey'] = info_tmp['pkey']
host_info['pkey_passwd'] = info_tmp['pkey_passwd']
return host_info

def modify_host(self,args):
Expand All @@ -837,6 +841,7 @@ def modify_host(self,args):
username: 用户名
password: 密码
pkey: 密钥(如果不为空,将使用密钥连接)
pkey_passwd: 密钥的密码
}
@return dict
'''
Expand Down Expand Up @@ -865,6 +870,7 @@ def modify_host(self,args):
host_info['username'] = args['username']
host_info['password'] = args['password']
host_info['pkey'] = args['pkey']
host_info['pkey_passwd'] = args['pkey_passwd']
if not host_info['pkey']: host_info['pkey'] = ''
result = self.set_attr(host_info)
if not result['status']: return result
Expand All @@ -886,6 +892,7 @@ def create_host(self,args):
username: 用户名
password: 密码
pkey: 密钥(如果不为空,将使用密钥连接)
pkey_passwd: 密钥的密码
}
@return dict
'''
Expand All @@ -908,6 +915,7 @@ def create_host(self,args):
host_info['username'] = args['username']
host_info['password'] = args['password']
host_info['pkey'] = args['pkey']
host_info['pkey_passwd'] = args['pkey_passwd']
result = self.set_attr(host_info)
if not result['status']: return result
self.save_ssh_info(args.host,host_info)
Expand Down

0 comments on commit dd6da1e

Please sign in to comment.