From fead46212447c57b29a5ae520965eba902267f93 Mon Sep 17 00:00:00 2001 From: ibuler Date: Sun, 28 Dec 2014 00:34:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=99=BB=E5=BD=95=E5=90=8D?= =?UTF-8?q?=E5=92=8C=E8=AE=B0=E5=BD=95=E6=97=A5=E5=BF=97=E4=B8=8D=E4=B8=80?= =?UTF-8?q?=E6=A0=B7=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- connect.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/connect.py b/connect.py index b687e864d..e604bcca9 100755 --- a/connect.py +++ b/connect.py @@ -37,6 +37,8 @@ CONF = ConfigParser() CONF.read(os.path.join(CURRENT_DIR, 'jumpserver.conf')) LOG_DIR = os.path.join(CURRENT_DIR, 'logs') KEY = CONF.get('web', 'key') +LOGIN_NAME = getpass.getuser() +#LOGIN_NAME = os.getlogin() def green_print(string): @@ -225,7 +227,7 @@ def verify_connect(username, part_ip): except (ObjectDoesNotExist, IndexError): red_print('Get get_connect_item Error.') else: - connect(username, password, host, port) + connect(username, password, host, port, LOGIN_NAME) 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]) -def connect(username, password, host, port): +def connect(username, password, host, port, login_name): """ Connect server. """ @@ -277,7 +279,7 @@ def connect(username, password, host, port): channel.send(login_msg) # Make ssh interactive tunnel - posix_shell(channel, username, host) + posix_shell(channel, login_name, host) # Shutdown channel socket channel.close() @@ -285,8 +287,6 @@ def connect(username, password, host, port): if __name__ == '__main__': - #login_name = os.getlogin() - login_name = getpass.getuser() print_prompt() try: while True: @@ -296,14 +296,14 @@ if __name__ == '__main__': print continue if option in ['P', 'p']: - print_user_host(login_name) + print_user_host(LOGIN_NAME) continue elif option in ['E', 'e']: pass elif option in ['Q', 'q']: sys.exit() else: - verify_connect(login_name, option) + verify_connect(LOGIN_NAME, option) except IndexError: pass