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
fa0ec1e7
Commit
fa0ec1e7
authored
Mar 17, 2015
by
root
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
connect
parent
98dfebc3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
5 deletions
+26
-5
connect.py
connect.py
+23
-3
jumpserver.conf
jumpserver.conf
+1
-1
api.py
jumpserver/api.py
+2
-1
ssh.py
ssh.py
+0
-0
No files found.
connect.py
View file @
fa0ec1e7
...
...
@@ -26,7 +26,7 @@ from juser.models import User
from
jasset.models
import
Asset
from
jlog.models
import
Log
from
jumpserver.views
import
PyCrypt
from
jumpserver.api
import
user_perm_asset_api
from
jumpserver.api
import
user_perm_asset_api
,
user_perm_group_api
try
:
import
termios
...
...
@@ -183,6 +183,15 @@ def get_user_host(username):
return
hosts_attr
def
get_user_hostgroup
(
username
):
"""Get the hostgroups of under the user control."""
groups_attr
=
{}
group_all
=
user_perm_group_api
(
username
)
for
group
in
group_all
:
groups_attr
[
group
.
name
]
=
[
group
.
id
,
group
.
comment
]
return
groups_attr
def
get_connect_item
(
username
,
ip
):
cryptor
=
PyCrypt
(
KEY
)
...
...
@@ -233,8 +242,9 @@ def print_prompt():
msg
=
"""
\033
[1;32m### Welcome Use JumpServer To Login. ###
\033
[0m
1) Type
\033
[32mIP ADDRESS
\033
[0m To Login.
2) Type
\033
[32mP/p
\033
[0m To Print The Servers You Available.
3) Type
\033
[32mE/e
\033
[0m To Execute Command On Several Servers.
4) Type
\033
[32mQ/q
\033
[0m To Quit.
3) Type
\033
[32mG/g
\033
[0m To Print The Server Groups You Available.
4) Type
\033
[32mE/e
\033
[0m To Execute Command On Several Servers.
5) Type
\033
[32mQ/q
\033
[0m To Quit.
"""
print
textwrap
.
dedent
(
msg
)
...
...
@@ -247,6 +257,13 @@ def print_user_host(username):
print
'
%
s --
%
s'
%
(
ip
,
hosts_attr
[
ip
][
1
])
def
print_user_hostgroup
(
username
):
group_attr
=
get_user_hostgroup
(
username
)
groups
=
group_attr
.
keys
()
for
g
in
groups
:
print
'
%
s --
%
s'
%
(
g
,
group_attr
[
g
][
1
])
def
connect
(
username
,
password
,
host
,
port
,
login_name
):
"""
Connect server.
...
...
@@ -362,6 +379,9 @@ if __name__ == '__main__':
if
option
in
[
'P'
,
'p'
]:
print_user_host
(
LOGIN_NAME
)
continue
elif
option
in
[
'G'
,
'g'
]:
print_user_hostgroup
(
LOGIN_NAME
)
continue
elif
option
in
[
'E'
,
'e'
]:
exec_cmd_servers
(
LOGIN_NAME
)
elif
option
in
[
'Q'
,
'q'
]:
...
...
jumpserver.conf
View file @
fa0ec1e7
...
...
@@ -9,7 +9,7 @@ database = jumpserver
[
ldap
]
ldap_enable
=
1
host_url
=
ldap
://
1
92
.
168
.
8
.
230
:
389
host_url
=
ldap
://
1
27
.
0
.
0
.
1
:
389
base_dn
=
dc
=
fengxing
,
dc
=
com
root_dn
=
cn
=
admin
,
dc
=
fengxing
,
dc
=
com
root_pw
=
123456
...
...
jumpserver/api.py
View file @
fa0ec1e7
...
...
@@ -10,7 +10,8 @@ from jasset.models import Asset, BisGroup
from
jlog.models
import
Log
def
user_perm_group_api
(
user
):
def
user_perm_group_api
(
username
):
user
=
User
.
objects
.
get
(
username
=
username
)
if
user
:
perm_list
=
[]
user_group_all
=
user
.
group
.
all
()
...
...
ssh.py
0 → 100644
View file @
fa0ec1e7
This diff is collapsed.
Click to expand it.
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