Commit ef12ea5f authored by guanghongwei's avatar guanghongwei

初始化github库

parent 9d6a3b6e
#!/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\""
\ No newline at end of file
#!/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"
\ No newline at end of file
#coding:utf-8
[db]
host = 127.0.0.1
port = 3306
user = root
password = redhat
db = jumpserver
[jumpserver]
log_dir = /opt/jumpserver/logs/
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_shell.sh
[vpn]
host_pptp = 172.16.2.74
pptp_port = 2001
pptp_user = yolu
pptp_pass_file = /etc/ppp/chap-secrets
host_openvpn = 111.205.130.9
openvpn_port = 2001
openvpn_user = yolu
\ No newline at end of file
This diff is collapsed.
File added
#!/bin/bash
if [ $USER = 'yolu' ] || [ $USER == 'root' ];then
echo ""
else
python /opt/jumpserver/jumpserver.pyo
if [ $USER == 'guanghongwei' ] || [ $USER == 'liufuhua' ];then
echo
else
exit 3
echo
fi
fi
\ No newline at end of file
-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: DES-EDE3-CBC,D5AF0CC627FA8B85
oQLAgKLelCYNGc7cP51Bx3b66GmCKHAEhqBCsrPEi4eYKV7D30WOp+sdp8F5RaK1
I/ZtGmv4jAaK4/KCBr2bGgH7cnkOhdj6T+ro9YVr92r5kD0gwHzYzbTCZP44N9Wn
83pUy4eUpMB659Y4TQgUAQVejyr1/ZZJSb8Kgah1xlLlM1ZSmK7PuqCSpBz16wil
TXrywWvsUhrAuAJh1NC7wr7mXm8tb2DMkT1+ckIQUqhOMJGEvgByI3SXUKR1c9lL
ZBh7RwukipvbujazxJxBvW50fLpdSDuBIxRsQhJ5PvYTV8BBwsp5KvbO5b/qkIOL
RUxY4q3o7fHtXiRf4vD9iD1U7F39UMnDIie6jk642oN4aYmvyc0SnVH8RcVarnCA
HkdZ/5c93BCZRovay6DoIumN/OmURe83A9hzsHnMg9hkLAapw5dmlsvtk307YWK8
YnAy7TMLS72RdAxSJHXN9U+U7QKDu47jiIkST3kwNLXYm4gvY7eFlg82Ux2h9Soh
R5qJ6pdYh1Ah/msbE9v/HkWCqhU6fD38MaAmcuCAoOh2LuI+32+2ZkCT04hPhzQL
AjfrMsUFKiH/+IrFtQ8CcwaFtVR9b/Ebe65SQuBXV3Bcrcx91MWKBjCpiB1rQQZ/
mxNh4jQmvUOJYhDv8D1TZMCLrAREt07uPLhL24klv6v4lf204xbLhdYA1kW/m/16
+oEH6CHMo8qVqWylATfya1Iv+htAXs6Pi65j6QQjyM/sQZ+Cn0enGSS5S9WIx+Ca
C+kbRBmxfwYXROu7NkmWexiU3a7VmTj/0yA8uRXY7jbEyGgupXiAeXa2/pRX2XRo
8MugyIoZzLxvkszQ90WxH/9hO+eNDY1Wo+ONo8deos3pogjeIPhiFQlx2EFowGcf
TcNFgluQliwVm5qEWe2SWoNlHgnI7rhus1yAexH/G2uJHpd8eid3Rn19Fh1TxD16
r/+I6TEp7u27Fc9T+HVXg46kXxf7+p0/fcHLxOk0A5wfLzQgB6fVvXoXoldWoomr
FXpKmDTDjTp15R1pVZ3eVtuJp3wA+N6YsL7F2NsmtKMaMrXuMwSwJUJPpFSD/DXe
BUcqSeQMwvwSgzH4qkBtJcQ6baEVgBvDeRKoVInZ9D7FpumTv5tSnsqyD0NBZsXC
qmA5Sk+w2CRW1Nbi/uSFdDACZo8iDhILJ9fHRtNLyB+BN2cN7dIQZlmOQxK3omqd
iCgu1q31iE8wgxzEnrtPxLWi/2jr7WX0NVFzE6Qjjpvqa+3k4MjNDeNfPKHJMK50
o8hf4jlSZxhjc4D+U9ksSJZOl6NyuLhpp8YlVSkZ/Oiz6U1reTf8qZUOkBgY5V2T
0N+Pwqs81nA4Hsh32MxuVIt0RLtp2uLUyeEHatEp3akABFvWWMWbxgbwsmOXtnsj
QxJQ6jL+CCvpufu34prkMeKPApqTrwHq9YLNBFgg4ts+pl8wHrFo1CFma2ljvFzq
8FNn8FDJcebasNmnJOvXTryqp/Qd85fKH0XuR100azmXnuRmxuDmNXfN/ejtne1b
ZyDrSEGOlr/GpxTLDtbSSu82I+XqvAicXsUqbOqWUPM2mAKtDVfaIQ==
-----END RSA PRIVATE KEY-----
\ No newline at end of file
#!/bin/bash
host=127.0.0.1
ldapassword=VNLqNCjpNBIetEoCA2h3
host2=172.16.2.74
host2_port=2001
\ No newline at end of file
dn: cn=guanghongwei,ou=Sudoers,dc=yolu,dc=com
objectClass: top
objectClass: sudoRole
cn: guanghongwei
sudoCommand: /bin/pwd
sudoHost: ALL
sudoOption: !authenticate
sudoRunAsUser: ALL
sudoUser: guanghongwei
#!/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}/sudouser.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 -e "s@guanghongwei@$username@g" ${sudo_file} > $user_sudo_file
ldapadd -x -h ${host} -w ${ldapassword} -D "cn=admin,dc=yolu,dc=com" -f $user_sudo_file
#!/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."
exit 3
fi
ldapdelete -x -h $host -D "cn=admin,dc=yolu,dc=com" -w $ldapassword "cn=$username,ou=Sudoers,dc=yolu,dc=com"
\ No newline at end of file
#!/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=yolu,dc=com" /tmp/passwd.ldif > /tmp/user.ldif
grep -A6 "dn: cn=$username,ou=Group,dc=yolu,dc=com" /tmp/group.ldif > /tmp/usergroup.ldif
ldapadd -x -h $host -w $ldapassword -D "cn=admin,dc=yolu,dc=com" -f /tmp/user.ldif
ldapadd -x -h $host -w $ldapassword -D "cn=admin,dc=yolu,dc=com" -f /tmp/usergroup.ldif
#!/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=yolu,dc=com" -w $ldapassword "uid=$username,ou=People,dc=yolu,dc=com"
ldapdelete -x -h $host -D "cn=admin,dc=yolu,dc=com" -w $ldapassword "cn=$username,ou=Group,dc=yolu,dc=com"
AutoSa
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="FacetManager">
<facet type="django" name="Django">
<configuration>
<option name="rootFolder" value="$MODULE_DIR$" />
<option name="settingsModule" value="AutoSa/settings.py" />
<option name="manageScript" value="manage.py" />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="TemplatesService">
<option name="TEMPLATE_CONFIGURATION" value="Django" />
</component>
</module>
<?xml version="1.0" encoding="UTF-8"?>
<component name="dataSourceStorage">
<data-source source="LOCAL" name="Django default" uuid="07aaf015-c2aa-41d6-b96d-c87a4776f9a8">
<database-info product="" version="" jdbc-version="" driver-name="" driver-version=""/>
</data-source>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DataSourceManagerImpl" format="xml" hash="3839561372">
<data-source source="LOCAL" name="Django default" uuid="07aaf015-c2aa-41d6-b96d-c87a4776f9a8">
<driver-ref>sqlite.xerial</driver-ref>
<jdbc-driver>com.mysql.jdbc.Driver</jdbc-driver>
<jdbc-url>jdbc:mysql://172.10.10.9/jumpserver</jdbc-url>
<user-name>root</user-name>
<user-password>dfd8dfcfdfcedfc2dfcbdfde</user-password>
<libraries />
</data-source>
</component>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 2.7.6 (C:/Python27/python.exe)" project-jdk-type="Python SDK" />
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/AutoSa.iml" filepath="$PROJECT_DIR$/.idea/AutoSa.iml" />
</modules>
</component>
</project>
<component name="DependencyValidationManager">
<state>
<option name="SKIP_IMPORT_STATEMENTS" value="false" />
</state>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="" />
</component>
</project>
This diff is collapsed.
from django.contrib import admin
# Register your models here.
from django.db import models
from UserManage.models import User
class Assets(models.Model):
id = models.AutoField(primary_key=True)
ip = models.CharField(max_length=20)
port = models.IntegerField(max_length=5)
comment = models.CharField(max_length=100, blank=True, null=True)
def __unicode__(self):
return '%s ' % self.ip
class AssetsUser(models.Model):
uid = models.ForeignKey(User)
aid = models.ForeignKey(Assets)
\ No newline at end of file
from django.test import TestCase
# Create your tests here.
from django.shortcuts import render
# Create your views here.
#coding:utf-8
def name_proc(request):
name = request.session.get('username')
admin = request.session.get('admin')
return {'name': name, 'admin': admin}
\ No newline at end of file
"""
Django settings for AutoSa project.
For more information on this file, see
https://docs.djangoproject.com/en/1.6/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.6/ref/settings/
"""
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
import ConfigParser
base_dir = "/opt/jumpserver/"
cf = ConfigParser.ConfigParser()
cf.read('%s/jumpserver.conf' % base_dir)
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
db_host = cf.get('db', 'host')
db_port = cf.getint('db', 'port')
db_user = cf.get('db', 'user')
db_password = cf.get('db', 'password')
db_db = cf.get('db', 'db')
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.6/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'tg-49xz3a#%5@^%83my*2up51)c3pove2_+21_(j*795gm38u*'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
TEMPLATE_DEBUG = True
ALLOWED_HOSTS = ['*']
# Application definition
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'UserManage',
'Assets',
#'RunCommand',
)
MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
#'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
)
ROOT_URLCONF = 'AutoSa.urls'
WSGI_APPLICATION = 'AutoSa.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.6/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': db_db,
'USER': db_user,
'PASSWORD': db_password,
'HOST': db_host,
'PORT': db_port,
}
}
TEMPLATE_CONTEXT_PROCESSORS = (
'django.contrib.auth.context_processors.auth',
'django.core.context_processors.debug',
'django.core.context_processors.i18n',
'django.core.context_processors.media',
'django.core.context_processors.static',
'django.core.context_processors.tz',
'django.contrib.messages.context_processors.messages',
'AutoSa.context_processors.name_proc',
)
TEMPLATE_DIRS = (
os.path.join(BASE_DIR, 'templates'),
)
#STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATICFILES_DIRS = (
os.path.join(BASE_DIR, "static"),
)
# Internationalization
# https://docs.djangoproject.com/en/1.6/topics/i18n/
LANGUAGE_CODE = 'zh-cn'
TIME_ZONE = 'Asia/Shanghai'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.6/howto/static-files/
STATIC_URL = '/static/'
SESSION_COOKIE_AGE = 3600
from django.conf.urls import patterns, include, url
from django.contrib import admin
from AutoSa import views
admin.autodiscover()
urlpatterns = patterns('',
# Examples:
# url(r'^$', 'AutoSa.views.home', name='home'),
# url(r'^blog/', include('blog.urls')),
url(r'^admin/', include(admin.site.urls)),
(r'^$', views.index),
(r'^login/$', views.login),
(r'^logout/$', views.logout),
(r'^showUser/$', views.showUser),
(r'^addUser/$', views.addUser),
(r'^showAssets/$', views.showAssets),
(r'^addAssets/$', views.addAssets),
(r'^showPerm/$', views.showPerm),
(r'^addPerm/$', views.addPerm),
(r'^downKey/$', views.downKey),
(r'^chgPass/$', views.chgPass),
(r'^chgKey/$', views.chgKey),
(r'^chgPptp/$', views.chgPptp),
(r'^chgOpenvpn/$', views.chgOpenvpn),
(r'^addPptp/$', views.addPptp),
(r'^addOpenvpn/$', views.addOpenvpn),
)
This diff is collapsed.
"""
WSGI config for AutoSa project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/1.6/howto/deployment/wsgi/
"""
import os
import sys
sys.path.append('/opt/jumpserver/webroot/AutoSa')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "AutoSa.settings")
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
from django.contrib import admin
# Register your models here.
from django.db import models
class Server(models.Model):
ip = models.CharField(max_length=16)
username = models.CharField(max_length=20)
password = models.CharField(max_length=30)
port = models.IntegerField(max_length=5)
sudo = models.BooleanField()
def __unicode__(self):
return self.ip
\ No newline at end of file
from django.shortcuts import render
from django.contrib import admin
# Register your models here.
from django.db import models
class User(models.Model):
username = models.CharField(max_length=50)
password = models.CharField(max_length=100)
name = models.CharField(max_length=50)
email = models.EmailField(max_length=50)
def __unicode__(self):
return self.username
\ No newline at end of file
from django.test import TestCase
# Create your tests here.
from django.shortcuts import render
# Create your views here.
#!/usr/bin/env python
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "AutoSa.settings")
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)
#!/bin/bash
./manage.py runserver 0.0.0.0:80
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/*!
* Bootstrap v3.0.3 (http://getbootstrap.com)
* Copyright 2013 Twitter, Inc.
* Licensed under http://www.apache.org/licenses/LICENSE-2.0
*/
/*设置全局字体*/
body,button, input, p, select, textarea,h1 ,h2, h3, h4, h5, h6 {
font-family: "Helvetica Neue", Helvetica, STheiti, "微软雅黑", "宋体", Arial, Tahoma, sans-serif, serif;}
/*左侧下拉菜单样式*/
/*左侧菜单*/
.sidebar-menu {
border-right: 1px solid #c4c8cb;
}
/*一级菜单*/
.menu-first {
height: 45px;
line-height: 45px;
background-color: #e9e9e9;
border-top: 1px solid #efefef;
border-bottom: 1px solid #e1e1e1;
padding: 0;
font-size: 14px;
font-weight: normal;
text-align: center;
}
/*一级菜单鼠标划过状态*/
.menu-first:hover {
text-decoration: none;
background-color: #d6d4d5;
border-top: 1px solid #b7b7b7;
border-bottom: 1px solid #acacac;
}
/*二级菜单*/
.menu-second li a {
background-color: #f6f6f6;
height: 31px;
line-height: 31px;
border-top: 1px solid #efefef;
border-bottom: 1px solid #efefef;
font-size: 12px;
text-align: center;
}
/*二级菜单鼠标划过样式*/
.menu-second li a:hover {
text-decoration: none;
background-color: #66c3ec;
border-top: 1px solid #83ceed;
border-bottom: 1px solid #83ceed;
border-right: 3px solid #f8881c;
border-left: 3px solid #66c3ec;
}
/*二级菜单选中状态*/
.menu-second-selected {
background-color: #66c3ec;
height: 31px;
line-height: 31px;
border-top: 1px solid #83ceed;
border-bottom: 1px solid #83ceed;
border-right: 3px solid #f8881c;
border-left: 3px solid #66c3ec;
text-align: center;
}
/*覆盖bootstrap的样式*/
.nav-list,.nav-list li a{
padding: 0px;
margin: 0px;
}
/*覆盖bootstrap的样式-大屏幕*/
.screen {
padding: 10px;
margin-bottom: 10px;
font-size: 12px;
font-weight: 200;
line-height: 2.1428571435;
color: inherit;
background-color: #eeeeee;
}
.jumbotron h1,
.jumbotron .h1 {
line-height: 1;
color: inherit;
}
.jumbotron p {
line-height: 1.4;
}
.container .jumbotron {
border-radius: 6px;
}
.jumbotron .container {
max-width: 100%;
}
@media screen and (min-width: 768px) {
.jumbotron {
padding-top: 48px;
padding-bottom: 48px;
}
.container .jumbotron {
padding-right: 60px;
padding-left: 60px;
}
.jumbotron h1,
.jumbotron .h1 {
font-size: 63px;
}
}
.control-label {
text-align: left !important;
}
.session_btn {
margin-right: 40px !important;
margin-top: 7px;
}
select.add-perm {
height: 300px !important;
}
/*li.dropdown-logout, ul.dropdown-logout {
min-width: 20px !important;
margin-right: 15px;
}*/
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment