mirror of https://github.com/jumpserver/jumpserver
修改登录名和记录日志不一样的问题
parent
42d14ee1d6
commit
fead462124
14
connect.py
14
connect.py
|
@ -37,6 +37,8 @@ CONF = ConfigParser()
|
||||||
CONF.read(os.path.join(CURRENT_DIR, 'jumpserver.conf'))
|
CONF.read(os.path.join(CURRENT_DIR, 'jumpserver.conf'))
|
||||||
LOG_DIR = os.path.join(CURRENT_DIR, 'logs')
|
LOG_DIR = os.path.join(CURRENT_DIR, 'logs')
|
||||||
KEY = CONF.get('web', 'key')
|
KEY = CONF.get('web', 'key')
|
||||||
|
LOGIN_NAME = getpass.getuser()
|
||||||
|
#LOGIN_NAME = os.getlogin()
|
||||||
|
|
||||||
|
|
||||||
def green_print(string):
|
def green_print(string):
|
||||||
|
@ -225,7 +227,7 @@ def verify_connect(username, part_ip):
|
||||||
except (ObjectDoesNotExist, IndexError):
|
except (ObjectDoesNotExist, IndexError):
|
||||||
red_print('Get get_connect_item Error.')
|
red_print('Get get_connect_item Error.')
|
||||||
else:
|
else:
|
||||||
connect(username, password, host, port)
|
connect(username, password, host, port, LOGIN_NAME)
|
||||||
|
|
||||||
|
|
||||||
def print_prompt():
|
def print_prompt():
|
||||||
|
@ -244,7 +246,7 @@ def print_user_host(username):
|
||||||
print '[%s] %s -- %s' % (hosts_attr[ip][0], ip, hosts_attr[ip][1])
|
print '[%s] %s -- %s' % (hosts_attr[ip][0], ip, hosts_attr[ip][1])
|
||||||
|
|
||||||
|
|
||||||
def connect(username, password, host, port):
|
def connect(username, password, host, port, login_name):
|
||||||
"""
|
"""
|
||||||
Connect server.
|
Connect server.
|
||||||
"""
|
"""
|
||||||
|
@ -277,7 +279,7 @@ def connect(username, password, host, port):
|
||||||
channel.send(login_msg)
|
channel.send(login_msg)
|
||||||
|
|
||||||
# Make ssh interactive tunnel
|
# Make ssh interactive tunnel
|
||||||
posix_shell(channel, username, host)
|
posix_shell(channel, login_name, host)
|
||||||
|
|
||||||
# Shutdown channel socket
|
# Shutdown channel socket
|
||||||
channel.close()
|
channel.close()
|
||||||
|
@ -285,8 +287,6 @@ def connect(username, password, host, port):
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
#login_name = os.getlogin()
|
|
||||||
login_name = getpass.getuser()
|
|
||||||
print_prompt()
|
print_prompt()
|
||||||
try:
|
try:
|
||||||
while True:
|
while True:
|
||||||
|
@ -296,14 +296,14 @@ if __name__ == '__main__':
|
||||||
print
|
print
|
||||||
continue
|
continue
|
||||||
if option in ['P', 'p']:
|
if option in ['P', 'p']:
|
||||||
print_user_host(login_name)
|
print_user_host(LOGIN_NAME)
|
||||||
continue
|
continue
|
||||||
elif option in ['E', 'e']:
|
elif option in ['E', 'e']:
|
||||||
pass
|
pass
|
||||||
elif option in ['Q', 'q']:
|
elif option in ['Q', 'q']:
|
||||||
sys.exit()
|
sys.exit()
|
||||||
else:
|
else:
|
||||||
verify_connect(login_name, option)
|
verify_connect(LOGIN_NAME, option)
|
||||||
except IndexError:
|
except IndexError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue