Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
J
jumpserver
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ops
jumpserver
Commits
fead4621
Commit
fead4621
authored
Dec 27, 2014
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改登录名和记录日志不一样的问题
parent
42d14ee1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
7 deletions
+7
-7
connect.py
connect.py
+7
-7
No files found.
connect.py
View file @
fead4621
...
...
@@ -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
,
user
name
,
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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment