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
6b1b3348
Commit
6b1b3348
authored
Nov 19, 2015
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
一些js, setting的KEY_DIR, 下载秘钥鉴定
parent
1471e0a2
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
31 additions
and
12 deletions
+31
-12
jumpserver.conf
jumpserver.conf
+1
-1
api.py
jumpserver/api.py
+3
-1
settings.py
jumpserver/settings.py
+1
-1
mytags.py
jumpserver/templatetags/mytags.py
+11
-0
user_api.py
juser/user_api.py
+3
-3
asset_edit_batch.html
templates/jasset/asset_edit_batch.html
+5
-5
user_list.html
templates/juser/user_list.html
+7
-1
No files found.
jumpserver.conf
View file @
6b1b3348
...
...
@@ -9,7 +9,7 @@ log = debug
host
=
127
.
0
.
0
.
1
port
=
3306
user
=
jumpserver
password
=
mysql
1
234
password
=
mysql234
database
=
jumpserver
[
websocket
]
...
...
jumpserver/api.py
View file @
6b1b3348
...
...
@@ -386,7 +386,7 @@ def bash(cmd):
return
subprocess
.
call
(
cmd
,
shell
=
True
)
def
mkdir
(
dir_name
,
mode
=
0755
):
def
mkdir
(
dir_name
,
username
=
'root'
,
mode
=
0755
):
"""
insure the dir exist and mode ok
目录存在,如果不存在就建立,并且权限正确
...
...
@@ -394,6 +394,8 @@ def mkdir(dir_name, mode=0755):
if
not
os
.
path
.
isdir
(
dir_name
):
os
.
makedirs
(
dir_name
)
os
.
chmod
(
dir_name
,
mode
)
if
username
:
bash
(
'chown
%
s:
%
s
%
s'
%
(
username
,
username
,
dir_name
))
def
http_success
(
request
,
msg
):
...
...
jumpserver/settings.py
View file @
6b1b3348
...
...
@@ -17,7 +17,7 @@ config = ConfigParser.ConfigParser()
BASE_DIR
=
os
.
path
.
abspath
(
os
.
path
.
dirname
(
os
.
path
.
dirname
(
__file__
)))
config
.
read
(
os
.
path
.
join
(
BASE_DIR
,
'jumpserver.conf'
))
KEY_DIR
=
os
.
path
.
join
(
BASE_DIR
,
'keys
/role_keys
'
)
KEY_DIR
=
os
.
path
.
join
(
BASE_DIR
,
'keys'
)
DB_HOST
=
config
.
get
(
'db'
,
'host'
)
...
...
jumpserver/templatetags/mytags.py
View file @
6b1b3348
...
...
@@ -226,3 +226,14 @@ def ip_str_to_list(ip_str):
ip str to list
"""
return
ip_str
.
split
(
','
)
@register.filter
(
name
=
'key_exist'
)
def
key_exist
(
username
):
"""
ssh key is exist or not
"""
if
os
.
path
.
isfile
(
os
.
path
.
join
(
KEY_DIR
,
'user'
,
username
)):
return
True
else
:
return
False
juser/user_api.py
View file @
6b1b3348
...
...
@@ -123,21 +123,21 @@ def db_del_user(username):
def
gen_ssh_key
(
username
,
password
=
''
,
key_dir
=
os
.
path
.
join
(
KEY_DIR
,
'user'
),
authorized_keys
=
True
,
home
=
"/home"
,
length
=
2048
):
"""
generate a user ssh key in a property dir
生成一个用户ssh密钥对
"""
logger
.
debug
(
'生成ssh key, 并设置authorized_keys'
)
private_key_file
=
os
.
path
.
join
(
key_dir
,
username
)
mkdir
(
private_key_file
,
username
)
mkdir
(
key_dir
)
if
os
.
path
.
isfile
(
private_key_file
):
os
.
unlink
(
private_key_file
)
ret
=
bash
(
'echo -e "y
\n
"|ssh-keygen -t rsa -f
%
s -b
%
s -P "
%
s"'
%
(
private_key_file
,
length
,
password
))
if
authorized_keys
:
auth_key_dir
=
os
.
path
.
join
(
home
,
username
,
'.ssh'
)
mkdir
(
auth_key_dir
,
username
,
mode
=
0700
)
mkdir
(
auth_key_dir
,
mode
=
0700
)
authorized_key_file
=
os
.
path
.
join
(
auth_key_dir
,
'authorized_keys'
)
with
open
(
private_key_file
+
'.pub'
)
as
pub_f
:
with
open
(
authorized_key_file
,
'w'
)
as
auth_f
:
...
...
templates/jasset/asset_edit_batch.html
View file @
6b1b3348
...
...
@@ -54,17 +54,17 @@
<div
class=
"col-sm-2"
>
<div
class=
"radio i-checks"
>
<label>
<input
type=
"radio"
checked=
""
value=
"no_action"
name=
"use_default_
auth"
><span>
不修改
</span>
<input
type=
"radio"
checked=
""
value=
"no_action"
id=
"no"
name=
"use_default_auth"
class=
"
auth"
><span>
不修改
</span>
</label>
</div>
<div
class=
"radio i-checks"
>
<label>
<input
type=
"radio"
name=
"use_default_
auth"
><span>
使用默认
</span>
<input
type=
"radio"
id=
"default"
name=
"use_default_auth"
class=
"
auth"
><span>
使用默认
</span>
</label>
</div>
<div
class=
"radio i-checks"
>
<label>
<input
type=
"radio"
id=
"
id_use_default_auth"
name=
"use_default_
auth"
><span>
用户名密码
</span>
<input
type=
"radio"
id=
"
pass"
name=
"use_default_auth"
class=
"
auth"
><span>
用户名密码
</span>
</label>
</div>
</div>
...
...
@@ -140,8 +140,8 @@
$
(
'#uuid'
).
val
(
ids
)
});
$
(
'
#id_use_default_
auth'
).
click
(
function
(){
if
(
$
(
this
).
is
(
':checked'
)
){
$
(
'
.
auth'
).
click
(
function
(){
if
(
$
(
this
).
attr
(
'id'
)
==
'pass'
){
$
(
'#admin_account'
).
css
(
'display'
,
'block'
)
}
else
{
...
...
templates/juser/user_list.html
View file @
6b1b3348
...
...
@@ -64,7 +64,13 @@
<td
class=
"text-center"
title=
"{% for user_group in user.group.all %} {{ user_group.name }} {% endfor %}"
>
{{ user.group.all | groups2str }}
</td>
<td
class=
"text-center"
>
{{ user.id | get_role }}
</td>
<td
class=
"text-center"
>
{{ user.is_active | bool2str }}
</td>
<td
class=
"text-center"
><a
href=
"/juser/down_key/?id={{ user.id }}"
>
下载
</a></td>
<td
class=
"text-center"
>
{% if user.username|key_exist %}
<a
href=
"/juser/down_key/?id={{ user.id }}"
>
下载
</a>
{% else %}
<span
style=
"color: #586b7d"
>
下载
</span>
{% endif %}
</td>
<td
class=
"text-center"
>
<a
href=
"../user_detail/?id={{ user.id }}"
class=
"btn btn-xs btn-primary"
>
详情
</a>
<a
href=
"../user_edit/?id={{ user.id }}"
class=
"btn btn-xs btn-info"
>
编辑
</a>
...
...
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