# setenforce 0 ## 能够设置配置文件永久关闭 # systemctl stop firewalld.service ## 修改字符集,不然可能报 input/output error的问题,由于日志里打印了中文 # localedef -c -f UTF-8 -i zh_CN zh_CN.UTF-8 # export LC_ALL=zh_CN.UTF-8 # echo 'LANG="zh_CN.UTF-8"' > /etc/locale.conf
# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup # wget http://mirrors.163.com/.help/CentOS7-Base-163.repo -O /etc/yum.repos.d/CentOS-Base.repo
# yum clean all
# yum makecache
# yum -y install wget sqlite-devel xz gcc automake zlib-devel openssl-devel epel-release git
# wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tar.xz # tar xvf Python-3.6.1.tar.xz && cd Python-3.6.1 # ./configure && make && make install ## CentOS7自带的是Python2,而Yum等工具依赖原来的Python,所以这里执行编译安装Python3
## 为了避免扰乱本来的环境,咱们使用Python虚拟环境 # cd /opt # python3 -m venv py3 # source /opt/py3/bin/activate ## 看到下面的提示符表明成功,之后运行Jumpserver都要先运行以上source命令,如下全部命令均在该虚拟环境中运行 (py3) [root@localhost py3]
## 此项仅为防止运行Jumpserver时忘记载入Python虚拟环境致使程序没法运行,这里使用autoenv # cd /opt # git clone git://github.com/kennethreitz/autoenv.git # echo 'source /opt/autoenv/activate.sh' >> ~/.bashrc # source ~/.bashrc
## 项目git clone时较大,你能够选择去Github项目页面直接下载zip包。 # cd /opt/ # git clone https://github.com/jumpserver/jumpserver.git && cd jumpserver && git checkout master # echo "source /opt/py3/bin/activate" > /opt/jumpserver/.env ## 进入jumpserver目录时将自动载入python虚拟环境 ## 首次进入jumpserver文件夹会有提示,按 y 便可 # Are you sure you want to allow this? (y/N) y
# cd /opt/jumpserver/requirements # yum -y install $(cat rpm_requirements.txt) ## 若是没有任何报错请继续
# pip install --upgrade pip ## 将pip更新至最新版
## 在~/.pip/pip.conf文件中添加或修改 [global] index-url = http://mirrors.aliyun.com/pypi/simple/ [install] trusted-host=mirrors.aliyun.com
##此步骤非必需,可是官方源的速度...
# pip install -r requirements.txt
## 若是加速镜像上没有所需依赖包可单独下载安装
## Jumpserver使用Redis作cache # yum -y install redis
# systemctl enable redis # systemctl start redis
## 这里使用Mysql做为数据库,若是不使用Mysql能够跳过相关Mysql安装和配置 # yum -y install mariadb mariadb-devel mariadb-server ## CentOS7下安装的是mariadb # systemctl enable mariadb # systemctl start mariadb
# mysql > create database jumpserver default charset 'utf8'; > grant all on jumpserver.* to 'jumpserver'@'127.0.0.1' identified by 'somepassword'; > flush privileges;
# cd /opt/jumpserver # cp config_example.py config.py # vi config.py
## 注意: 配置文件是Python格式,不要用TAB,而要用空格 """ jumpserver.config ~~~~~~~~~~~~~~~~~ Jumpserver project setting file :copyright: (c) 2014-2017 by Jumpserver Team :license: GPL v2, see LICENSE for more details. """ import os BASE_DIR = os.path.dirname(os.path.abspath(__file__)) class Config: # Use it to encrypt or decrypt data # Jumpserver 使用SECRET_KEY进行加密,请务必修改如下设置 # SECRET_KEY = os.environ.get('SECRET_KEY') or '2vym+ky!997d5kkcc64mnz06y1mmui3lut#(^wd=%s_qj$1%x' SECRET_KEY = '请随意输入随机字符串(推荐字符大于等于 50位)' # Django security setting, if your disable debug model, you should setting that ALLOWED_HOSTS = ['*'] # DEBUG 模式 True为开启 False为关闭,默认开启,生产环境推荐关闭 # 注意:若是设置了DEBUG = False,访问8080端口页面会显示不正常,须要搭建Nginx代理才能够正常访问了 DEBUG = False # 日志级别,默认为DEBUG,可调整为INFO, WARNING, ERROR, CRITICAL,默认INFO LOG_LEVEL = 'ERROR' LOG_DIR = os.path.join(BASE_DIR, 'logs') # 使用的数据库配置,支持sqlite3, mysql, postgres等,默认使用sqlite3 # See https://docs.djangoproject.com/en/1.10/ref/settings/#databases # 默认使用SQLite,若是使用其余数据库请注释下面两行 # DB_ENGINE = 'sqlite3' # DB_NAME = os.path.join(BASE_DIR, 'data', 'db.sqlite3') # # 若是须要使用mysql或postgres,请取消下面的注释并输入正确的信息,本例使用mysql作演示 DB_ENGINE = 'mysql' DB_HOST = '127.0.0.1' DB_PORT = 3306 DB_USER = 'jumpserver' DB_PASSWORD = 'somepassword' DB_NAME = 'jumpserver' # Django 监听的ip和端口,生产环境推荐把0.0.0.0修改为127.0.0.1,这里的意思是容许x.x.x.x访问,127.0.0.1表示仅容许自身访问 # ./manage.py runserver 127.0.0.1:8080 HTTP_BIND_HOST = '127.0.0.1' HTTP_LISTEN_PORT = 8080 # Redis 相关设置 REDIS_HOST = '127.0.0.1' REDIS_PORT = 6379 REDIS_PASSWORD = '' def __init__(self): pass def __getattr__(self, item): return None class DevelopmentConfig(Config): pass class TestConfig(Config): pass class ProductionConfig(Config): pass # Default using Config settings, you can write if/else for different env config = DevelopmentConfig()
# cd /opt/jumpserver/utils # bash make_migrations.sh
# cd /opt/jumpserver # ./jms start all # 后台运行使用 -d 参数./jms start all -d ## 新版本更新了运行脚本,使用方式./jms start|stop|status|restart all 后台运行请添加 -d 参数
## 运行不报错,请浏览器访问 http://10.10.10.128:8080/ 默认帐号: admin 密码: admin 页面显示不正常先不用处理,跟着教程继续操做就行,后面搭建nginx代理就能够正常访问了
# cd /opt # source /opt/py3/bin/activate # git clone https://github.com/jumpserver/coco.git && cd coco && git checkout master # echo "source /opt/py3/bin/activate" > /opt/coco/.env ## 进入coco目录时将自动载入python虚拟环境 # 首次进入coco文件夹会有提示,按 y 便可 # Are you sure you want to allow this? (y/N) y
# cd /opt/coco/requirements # yum -y install $(cat rpm_requirements.txt) # pip install -r requirements.txt
# cd /opt/coco # cp conf_example.py conf.py ## 若是coco与jumpserver分开部署,请手动修改conf.py # vi conf.py
## 注意: 配置文件是Python格式,不要用TAB,而要用空格 #!/usr/bin/env python3 # -*- coding: utf-8 -*- # import os BASE_DIR = os.path.dirname(__file__) class Config: """ Coco config file, coco also load config from server update setting below """ # 项目名称, 会用来向Jumpserver注册, 识别而已, 不能重复 # NAME = "localhost" NAME = "coco" # Jumpserver项目的url, api请求注册会使用, 若是Jumpserver没有运行在127.0.0.1:8080,请修改此处 # CORE_HOST = os.environ.get("CORE_HOST") or 'http://127.0.0.1:8080' CORE_HOST = 'http://127.0.0.1:8080' # 启动时绑定的ip, 默认 0.0.0.0 # BIND_HOST = '0.0.0.0' # 监听的SSH端口号, 默认2222 # SSHD_PORT = 2222 # 监听的HTTP/WS端口号,默认5000 # HTTPD_PORT = 5000 # 项目使用的ACCESS KEY, 默认会注册,并保存到ACCESS_KEY_STORE中, # 若是有需求, 能够写到配置文件中, 格式access_key_id:access_key_secret # ACCESS_KEY = None # ACCESS KEY保存的地址, 默认注册后会保存到该文件中 # ACCESS_KEY_STORE = os.path.join(BASE_DIR, 'keys', '.access_key') # 加密密钥 # SECRET_KEY = None # 设置日志级别 ['DEBUG', 'INFO', 'WARN', 'ERROR', 'FATAL', 'CRITICAL'] # LOG_LEVEL = 'INFO' # 日志存放的目录 # LOG_DIR = os.path.join(BASE_DIR, 'logs') # Session录像存放目录 # SESSION_DIR = os.path.join(BASE_DIR, 'sessions') # 资产显示排序方式, ['ip', 'hostname'] # ASSET_LIST_SORT_BY = 'ip' # 登陆是否支持密码认证 # PASSWORD_AUTH = True # 登陆是否支持秘钥认证 # PUBLIC_KEY_AUTH = True # 和Jumpserver 保持心跳时间间隔 # HEARTBEAT_INTERVAL = 5 # Admin的名字,出问题会提示给用户 # ADMINS = '' COMMAND_STORAGE = { "TYPE": "server" } REPLAY_STORAGE = { "TYPE": "server" } config = Config() # ./cocod start ## 后台运行使用 -d 参数./cocod start -d ## 新版本更新了运行脚本,使用方式./cocod start|stop|status|restart 后台运行请添加-d参数
## 启动成功后去Jumpserver会话管理-终端管理(http://10.10.10.128:8080/terminal/terminal/)接受coco的注册,若是页面不正常能够等部署完成后再处理
## Luna已改成纯前端,须要Nginx来运行访问 # cd /opt # wget https://github.com/jumpserver/luna/releases/download/1.3.2/luna.tar.gz # tar xvf luna.tar.gz # chown -R root:root luna
由于手动安装guacamole组件比较复杂,这里提供打包好的docker使用, 启动guacamolehtml
# yum remove docker-latest-logrotate docker-logrotate docker-selinux dockdocker-engine # yum install -y yum-utils device-mapper-persistent-data lvm2 # 添加docker官方源 # yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo # yum makecache fast # yum install docker-ce # 国内部分用户可能没法链接docker官网提供的源,这里提供阿里云的镜像节点供测试使用 # yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo # rpm --import http://mirrors.aliyun.com/docker-ce/linux/centos/gpg # yum makecache fast # yum -y install docker-ce # systemctl start docker # systemctl status docker
## 这里使用阿里云镜像加速器 Docker客户端版本需大于1.10.0 ## 经过修改daemon配置文件/etc/docker/daemon.json来使用加速器 # mkdir -p /etc/docker # tee /etc/docker/daemon.json <<-'EOF' { "registry-mirrors": ["https://2x42e901.mirror.aliyuncs.com"] } EOF # systemctl daemon-reload # systemctl restart docker
## 此步骤非必须,可是速度你懂的...
这里所须要注意的是guacamole暴露出来的端口是 8081,若与主机上其余端口冲突请自定义前端
修改下面docker run里的JUMPSERVER_SERVER参数,填上Jumpserver的url地址python
启动成功后去Jumpserver会话管理-终端管理(http://10.10.10.128:8080/terminal/terminal/)接受注册,若是页面显示不正常能够等部署完成后再处理mysql
# docker run --name jms_guacamole -d \ -p 8081:8080 -v /opt/guacamole/key:/config/guacamole/key \ -e JUMPSERVER_KEY_DIR=/config/guacamole/key \ -e JUMPSERVER_SERVER=http://<填写jumpserver的url地址>:8080 \ registry.jumpserver.org/public/guacamole:latest
# yum -y install nginx
# vim /etc/nginx/nginx.conf ... 省略 # 把默认server配置块改为这样 server { listen 80; # 代理端口,之后将经过此端口进行访问,再也不经过8080端口 proxy_set_header X-Real-IP $remote_addr; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; location /luna/ { try_files $uri / /index.html; alias /opt/luna/; } location /media/ { add_header Content-Encoding gzip; root /opt/jumpserver/data/; } location /static/ { root /opt/jumpserver/data/; } location /socket.io/ { proxy_pass http://localhost:5000/socket.io/; # 若是coco安装在别的服务器,请填写它的ip proxy_buffering off; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } location /guacamole/ { proxy_pass http://localhost:8081/; # 若是guacamole安装在别的服务器,请填写它的ip proxy_buffering off; proxy_http_version 1.1; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $http_connection; access_log off; client_max_body_size 100m; # Windows 文件上传大小限制 } location / { proxy_pass http://localhost:8080; # 若是jumpserver安装在别的服务器,请填写它的ip } } ... 省略
# nginx -t ## 确保配置没有问题, 有问题请先解决
# systemctl start nginx
# systemctl enable nginx
## 检查应用是否已经正常运行 # cd /opt/jumpserver # ./jms status ## 肯定jumpserver已经运行,若是没有运行请从新启动jumpserver # cd /opt/coco # ./cocod status ## 肯定coco已经运行,若是没有运行请从新启动coco ## 若是安装了Guacamole # docker ps ## 检查容器是否已经正常运行,若是没有运行请从新启动Guacamole
服务所有启动后,访问 http://10.10.10.128,访问Nginx代理的端口,不要再经过8080端口访问linux
默认帐号: admin 密码: adminnginx
若是部署过程当中没有接受应用的注册,须要到Jumpserver会话管理-终端管理 接受Coco、Guacamole等应用的注册。git
若是登陆客户端是macOS或Linux ,登陆语法以下 # ssh -p2222 admin@192.168.244.144 # sftp -P2222 admin@192.168.244.144 密码: admin 若是登陆客户端是Windows,Xshell Terminal登陆语法以下 # ssh admin@192.168.244.144 2222 # sftp admin@192.168.244.144 2222 密码: admin 若是能登录表明部署成功 ## sftp默认上传的位置在资产的/tmp目录下 ## windows拖拽上传的位置在资产的Guacamole RDP上的G目录下
若是有安装和使用上的疑问请访问Jumpserver官方网站http://www.jumpserver.orggithub