mirror of https://github.com/jumpserver/jumpserver
删除没用的代码,添加上传文件
parent
1b08c6ea88
commit
68e8c4ba0f
21
chgpass.sh
21
chgpass.sh
|
@ -1,21 +0,0 @@
|
|||
#!/bin/bash
|
||||
username=$1
|
||||
password=$2
|
||||
|
||||
cwd (){
|
||||
dir=$0
|
||||
dirname $dir
|
||||
}
|
||||
|
||||
dir=$(cwd)
|
||||
. ${dir}/shell.conf
|
||||
|
||||
id ${username} &> /dev/null
|
||||
if [ $? != 0 ];then
|
||||
echo "$username is not exist."
|
||||
exit 3
|
||||
fi
|
||||
|
||||
echo "$password" | passwd --stdin "$username"
|
||||
|
||||
#ssh -p $host2_port $host2 "echo \"$password\" | passwd --stdin \"$username\""
|
37
genkey.sh
37
genkey.sh
|
@ -1,37 +0,0 @@
|
|||
#!/bin/bash
|
||||
user=$1
|
||||
password=$2
|
||||
|
||||
cwd (){
|
||||
dir=$0
|
||||
dirname $dir
|
||||
}
|
||||
|
||||
dir=$(cwd)
|
||||
. ${dir}/shell.conf
|
||||
|
||||
keyfile=${dir}/keys/${user}
|
||||
rm -f ${keyfile}
|
||||
|
||||
gen_key() {
|
||||
ssh-keygen -t rsa -f ${keyfile} -P $1
|
||||
}
|
||||
|
||||
if [ -z $1 ] || [ -z $2 ];then
|
||||
echo "Usage: ./script user password"
|
||||
exit 3
|
||||
fi
|
||||
|
||||
gen_key ${password}
|
||||
|
||||
mkdir -p /home/${user}/.ssh
|
||||
#ssh -p ${host2_port} ${host2} "mkdir -p /home/$user/.ssh"
|
||||
|
||||
cat ${keyfile}.pub > /home/${user}/.ssh/authorized_keys
|
||||
#ssh -p ${host2_port} ${host2} "cat > /home/$user/.ssh/authorized_keys" < ${keyfile}.pub
|
||||
|
||||
chmod 600 /home/${user}/.ssh/authorized_keys
|
||||
#ssh -p ${host2_port} ${host2} "chmod 600 /home/$user/.ssh/authorized_keys"
|
||||
|
||||
chown -R ${user}:${user} /home/${user}/.ssh
|
||||
#ssh -p ${host2_port} ${host2} "chown -R $user:$user /home/$user/.ssh"
|
|
@ -13,12 +13,6 @@ user_table = UserManage_user
|
|||
assets_table = Assets_assets
|
||||
assets_user_table = Assets_assetsuser
|
||||
key = 88aaaf7ffe3c6c04
|
||||
useradd_shell = /opt/jumpserver/useradd.sh
|
||||
userdel_shell = /opt/jumpserver/userdel.sh
|
||||
sudoadd_shell = /opt/jumpserver/sudoadd.sh
|
||||
sudodel_shell = /opt/jumpserver/sudodel.sh
|
||||
keygen_shell = /opt/jumpserver/genkey.sh
|
||||
chgpass_shell = /opt/jumpserver/chgpass.sh
|
||||
rsa_dir = /opt/jumpserver/keys
|
||||
ldap_host = ldap://127.0.0.1:389
|
||||
ldap_base_dn = dc=yolu,dc=com
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
host=127.0.0.1
|
||||
ldapassword=VNLqNCjpNBIetEoCA2h3
|
||||
domain=yolu
|
||||
suffix=com
|
||||
#host2=172.16.2.74
|
||||
#host2_port=2001
|
|
@ -1,9 +0,0 @@
|
|||
dn: cn=guanghongwei,ou=Sudoers,dc=dianping,dc=com
|
||||
objectClass: top
|
||||
objectClass: sudoRole
|
||||
cn: guanghongwei
|
||||
sudoCommand: /bin/pwd
|
||||
sudoHost: ALL
|
||||
sudoOption: !authenticate
|
||||
sudoRunAsUser: ALL
|
||||
sudoUser: guanghongwei
|
36
sudoadd.sh
36
sudoadd.sh
|
@ -1,36 +0,0 @@
|
|||
#!/bin/bash
|
||||
username=$1
|
||||
password=$2
|
||||
|
||||
cwd (){
|
||||
dir=$0
|
||||
dirname $dir
|
||||
}
|
||||
|
||||
dir=$(cwd)
|
||||
. ${dir}/shell.conf
|
||||
|
||||
|
||||
sudo_file=${dir}/sudo.ldif
|
||||
user_sudo_file=${dir}/${username}.ldif
|
||||
|
||||
if [ -z $1 ];then
|
||||
echo
|
||||
echo "usage: ./sudoadd.sh username "
|
||||
echo
|
||||
exit 3
|
||||
fi
|
||||
|
||||
id ${username} &> /dev/null
|
||||
if [ $? != '0' ];then
|
||||
echo "$username is not exit!"
|
||||
exit 3
|
||||
fi
|
||||
|
||||
sed -i "/guanghongwei/ s@dianping@$domain@g" ${sudo_file}
|
||||
sed -i "/guanghongwei/ s@com@$suffix@g" ${sudo_file}
|
||||
sed -e "s@guanghongwei@$username@g" ${sudo_file} > $user_sudo_file
|
||||
|
||||
|
||||
ldapadd -x -h ${host} -w ${ldapassword} -D "cn=admin,dc=$domain,dc=$suffix" -f $user_sudo_file
|
||||
rm -f $user_sudo_file
|
18
sudodel.sh
18
sudodel.sh
|
@ -1,18 +0,0 @@
|
|||
#!/bin/bash
|
||||
username=$1
|
||||
password=$2
|
||||
|
||||
cwd (){
|
||||
dir=$0
|
||||
dirname $dir
|
||||
}
|
||||
dir=$(cwd)
|
||||
. ${dir}/shell.conf
|
||||
|
||||
id $username &> /dev/null
|
||||
if [ $? == '0' ];then
|
||||
userdel -r $username
|
||||
else
|
||||
echo "$username is not exist."
|
||||
fi
|
||||
ldapdelete -x -h $host -D "cn=admin,dc=$domain,dc=$suffix" -w $ldapassword "cn=$username,ou=Sudoers,dc=$domain,dc=$suffix"
|
38
useradd.sh
38
useradd.sh
|
@ -1,38 +0,0 @@
|
|||
#!/bin/bash
|
||||
username=$1
|
||||
password=$2
|
||||
|
||||
cwd (){
|
||||
dir=$0
|
||||
dirname $dir
|
||||
}
|
||||
|
||||
dir=$(cwd)
|
||||
. ${dir}/shell.conf
|
||||
|
||||
if [ -z $1 ] || [ -z $2 ];then
|
||||
echo
|
||||
echo "usage: ./useradd.sh username password"
|
||||
echo
|
||||
exit 3
|
||||
fi
|
||||
|
||||
id $username &> /dev/null
|
||||
if [ $? != '0' ];then
|
||||
useradd $username
|
||||
#ssh -p $host2_port $host2 "useradd $username"
|
||||
echo $password | passwd --stdin $username
|
||||
else
|
||||
echo "$username have been exits."
|
||||
exit 5
|
||||
fi
|
||||
|
||||
cd /usr/share/migrationtools/
|
||||
./migrate_passwd.pl /etc/passwd > /tmp/passwd.ldif
|
||||
./migrate_group.pl /etc/group > /tmp/group.ldif
|
||||
|
||||
grep -A15 "dn: uid=$username,ou=People,dc=$domain,dc=$suffix" /tmp/passwd.ldif > /tmp/user.ldif
|
||||
grep -A6 "dn: cn=$username,ou=Group,dc=$domain,dc=$suffix" /tmp/group.ldif > /tmp/usergroup.ldif
|
||||
|
||||
ldapadd -x -h $host -w $ldapassword -D "cn=admin,dc=$domain,dc=$suffix" -f /tmp/user.ldif
|
||||
ldapadd -x -h $host -w $ldapassword -D "cn=admin,dc=$domain,dc=$suffix" -f /tmp/usergroup.ldif
|
21
userdel.sh
21
userdel.sh
|
@ -1,21 +0,0 @@
|
|||
#!/bin/bash
|
||||
username=$1
|
||||
password=$2
|
||||
|
||||
cwd (){
|
||||
dir=$0
|
||||
dirname $dir
|
||||
}
|
||||
|
||||
dir=$(cwd)
|
||||
. ${dir}/shell.conf
|
||||
|
||||
id $username &> /dev/null
|
||||
if [ $? == '0' ];then
|
||||
userdel -r $username
|
||||
#ssh -p $host2_port $host2 "userdel -r $username"
|
||||
else
|
||||
echo "$username is not exist."
|
||||
fi
|
||||
ldapdelete -x -h $host -D "cn=admin,dc=$domain,dc=$suffix" -w $ldapassword "uid=$username,ou=People,dc=$domain,dc=$suffix"
|
||||
ldapdelete -x -h $host -D "cn=admin,dc=$domain,dc=$suffix" -w $ldapassword "cn=$username,ou=Group,dc=$domain,dc=$suffix"
|
|
@ -25,13 +25,6 @@ cf.read('%s/jumpserver.conf' % base_dir)
|
|||
|
||||
key = cf.get('jumpserver', 'key')
|
||||
rsa_dir = cf.get('jumpserver', 'rsa_dir')
|
||||
useradd_shell = cf.get('jumpserver', 'useradd_shell')
|
||||
userdel_shell = cf.get('jumpserver', 'userdel_shell')
|
||||
sudoadd_shell = cf.get('jumpserver', 'sudoadd_shell')
|
||||
sudodel_shell = cf.get('jumpserver', 'sudodel_shell')
|
||||
keygen_shell = cf.get('jumpserver', 'keygen_shell')
|
||||
chgpass_shell = cf.get('jumpserver', 'chgpass_shell')
|
||||
admin = ['admin']
|
||||
ldap_host = cf.get('jumpserver', 'ldap_host')
|
||||
ldap_base_dn = cf.get('jumpserver', 'ldap_base_dn')
|
||||
admin_cn = cf.get('jumpserver', 'admin_cn')
|
||||
|
@ -684,10 +677,10 @@ def showAssets(request):
|
|||
assets = []
|
||||
username = request.session.get('username')
|
||||
user = User.objects.get(username=username)
|
||||
for asset in user.assetsuser_set.all():
|
||||
for asset in user.assetsuser_set.all().order_by('ip'):
|
||||
assets.append(asset.aid)
|
||||
else:
|
||||
assets = Assets.objects.all()
|
||||
assets = Assets.objects.all().order_by('ip')
|
||||
if request.method == 'POST':
|
||||
if request.session.get('admin') < 2:
|
||||
return HttpResponseRedirect('/showAssets/')
|
||||
|
@ -747,7 +740,7 @@ def showPerm(request):
|
|||
if request.GET.get('username'):
|
||||
username = request.GET.get('username')
|
||||
user = User.objects.get(username=username)
|
||||
assets_user = AssetsUser.objects.filter(uid=user.id).order_by()
|
||||
assets_user = AssetsUser.objects.filter(uid=user.id)
|
||||
return render_to_response('perms.html',
|
||||
{'user': user, 'assets': assets_user, 'perm_menu': 'active'},
|
||||
context_instance=RequestContext(request))
|
||||
|
@ -887,3 +880,21 @@ def chgKey(request):
|
|||
|
||||
return render_to_response('info.html', {'msg': '修改密码成功'})
|
||||
|
||||
|
||||
@login_required
|
||||
def upFile(request):
|
||||
username = request.session.get('username')
|
||||
msg = ''
|
||||
error = ''
|
||||
upload_dir = '/tmp/upload/'
|
||||
if request.method == 'POST':
|
||||
host = request.POST.get('host')
|
||||
path = request.POST.get('path')
|
||||
upload_file = request.FILES.get('file', None)
|
||||
|
||||
return HttpResponse('%s: %s' % (upload_file.name, upload_file.size))
|
||||
|
||||
|
||||
return render_to_response('upFile.html',
|
||||
{'username': username},
|
||||
context_instance=RequestContext(request))
|
|
@ -47,11 +47,23 @@
|
|||
<div class="row>
|
||||
<!--Sidebar content-->
|
||||
<div class="sidebar-menu">
|
||||
<div class="menu-first" ><a href="#userMenu" data-toggle="collapse"><i class="glyphicon glyphicon-th"></i> 密码管理</a></div>
|
||||
<div class="menu-first" ><a href="#userMenu" data-toggle="collapse">
|
||||
<i class="glyphicon glyphicon-th"></i> 密码管理</a>
|
||||
</div>
|
||||
<ul id="userMenu" class="nav nav-list navbar-collapse.in menu-second">
|
||||
<li><a href="/chgPass/"><i class="glyphicon glyphicon-send"></i> 登陆密码</a></li>
|
||||
<li><a href="/chgKey/"><i class="glyphicon glyphicon-send"></i> 密钥密码</a></li>
|
||||
</ul>
|
||||
|
||||
<div class="menu-first" ><a href="#fileMenu" data-toggle="collapse">
|
||||
<i class="glyphicon glyphicon-th"></i> 文件传输</a>
|
||||
</div>
|
||||
<ul id="fileMenu" class="nav nav-list navbar-collapse.in menu-second">
|
||||
<li><a href="/upFile/"><i class="glyphicon glyphicon-send"></i> 上传文件</a></li>
|
||||
<li><a href="/downFile/"><i class="glyphicon glyphicon-send"></i> 下载文件</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -109,6 +121,12 @@
|
|||
<li><a href="/showPerm/"><i class="glyphicon glyphicon-send"></i> 查看权限</a></li>
|
||||
<li><a href="/addPerm/"><i class="glyphicon glyphicon-send"></i> 添加权限</a></li>
|
||||
</ul>
|
||||
<div class="menu-first" ><a href="#fileMenu" data-toggle="collapse">
|
||||
<i class="glyphicon glyphicon-th"></i> 文件传输</a>
|
||||
</div>
|
||||
<ul id="fileMenu" class="nav nav-list navbar-collapse.in menu-second">
|
||||
<li><a href="/upFile/"><i class="glyphicon glyphicon-send"></i> 上传文件</a></li>
|
||||
<li><a href="/downFile/"><i class="glyphicon glyphicon-send"></i> 下载文件</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
{% endif %}
|
||||
|
||||
{% if error %}
|
||||
<div class="alert alert-danger"><b>错误:</b>{{ error }}</div>
|
||||
<div class="alert alert-danger" style="margin-left: auto;margin-right: auto;margin-top: 60px;width:500px;"><b>错误:</b>{{ error }}</div>
|
||||
{% endif %}
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
{% extends 'base.html' %}
|
||||
{% block content %}
|
||||
<form class="form-horizontal" enctype="multipart/form-data" role="form" method="post" action="" >
|
||||
<fieldset >
|
||||
<legend>{{ username }} -- 上传文件</legend>
|
||||
{% if error %}
|
||||
<div class="alert alert-danger">
|
||||
{{ error }}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if msg %}
|
||||
<div class="alert alert-success">
|
||||
{{ msg }}
|
||||
</div>
|
||||
{% endif %}
|
||||
<input type="text" name="username" value="{{ username }}" hidden="hidden">
|
||||
<div class="form-group">
|
||||
<label for="host" class="col-sm-2 control-label">服务器IP<span style="color: red"> *</span></label>
|
||||
<div class="col-sm-4">
|
||||
<input type="text" class="form-control" id="host" name="host" placeholder="IP">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="path" class="col-sm-2 control-label">上传目录<span style="color: red"> *</span></label>
|
||||
<div class="col-sm-4">
|
||||
<input type="text" class="form-control" id="path" name="path" placeholder="服务器目录">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="file" class="col-sm-2 control-label">上传目录<span style="color: red"> *</span></label>
|
||||
<div class="col-sm-4">
|
||||
<input type="file" class="form-control" id="file" name="file" placeholder="点击添加">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-sm-offset-2 col-sm-4">
|
||||
<button class="btn btn-primary">上传</button>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
{% endblock %}
|
Loading…
Reference in New Issue