环境

  • 系统:Centos 7.4

  • 阿里云ECS,单独绑定弹性公网IP

  • 关闭selinux,防火墙对本机公司IP全开

      #CentOS 7
    $ setenforce 0 # 临时关闭,重启后失效
    #修改字符集,否则可能报 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

1.安装python3

1.1 安装依赖包

$ yum -y install wget sqlite-devel xz gcc automake zlib-devel openssl-devel epel-release git

1.2 编译安装

$ 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 --prefix=/usr/local/python-3.6.1 && make && make install # 这里必须执行编译安装,否则在安装 Python 库依赖时会有麻烦...

1.3 创建Python虚拟环境

# 因为 CentOS 6/7 自带的是 Python2,而 Yum 等工具依赖原来的 Python,为了不扰乱原来的环境我们来使用 Python 虚拟环境
$ cd /opt
$ /usr/local/python-3.6.1/bin/python3 -m venv py3
$ source /opt/py3/bin/activate # 看到下面的提示符代表成功,以后运行 Jumpserver 都要先运行以上 source 命令,以下所有命令均在该虚拟环境中运行
(py3) [root@localhost py3]

2. 安装 JumpServer

2.1 下载或Clone项目

# 项目提交较多 git clone 时较大,你可以选择去 Github 项目页面直接下载zip包。
$ cd /opt/
$ git clone https://github.com/jumpserver/jumpserver.git && cd jumpserver && git checkout master

2.2 安装依赖RPM包

$ cd /opt/jumpserver/requirements
$ yum -y install $(cat rpm_requirements.txt)
# 如果没有任何报错请继续

2.3 安装python依赖

$ pip install -r requirements.txt
# 不要指定-i参数,因为镜像上可能没有最新的包,如果没有任何报错请继续

2.4 安装 Redis (Jumpserver 使用 Redis 做 cache 和 celery broke)

$ yum -y install redis
$ systemctl enable redis
$ systemctl start redis

2.5 安装 MySQL

centos7

$ yum -y install mariadb mariadb-devel mariadb-server # centos7下安装的是mariadb
$ systemctl enable mariadb
$ systemctl start mariadb
# 进入mysql空实例初始化所有空密码
$ mysql
> update mysql.user set password=password('xxxx'); flush privileges;

2.6 创建数据库 jumpserver 并授权

$ mysql
> create database jumpserver default charset 'utf8';
> grant all on jumpserver.* to 'jumpserver'@'127.0.0.1' identified by 'somepassword';
> flush privileges;

2.7 修改 JumpServer 配置文件

$ 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 = os.environ.get("DEBUG") or False # 日志级别,默认为DEBUG,可调整为INFO, WARNING, ERROR, CRITICAL,默认INFO
LOG_LEVEL = os.environ.get("LOG_LEVEL") or 'WARNING'
LOG_DIR = os.path.join(BASE_DIR, 'logs') # 使用的数据库配置,支持sqlite3, mysql, postgres等,默认使用sqlite3
# See https://docs.djangoproject.com/en/1.10/ref/settings/#databases # 默认使用SQLite3,如果使用其他数据库请注释下面两行
# DB_ENGINE = 'sqlite3'
# DB_NAME = os.path.join(BASE_DIR, 'data', 'db.sqlite3') # 如果需要使用mysql或postgres,请取消下面的注释并输入正确的信息,本例使用mysql做演示(mariadb也是mysql)
DB_ENGINE = os.environ.get("DB_ENGINE") or 'mysql'
DB_HOST = os.environ.get("DB_HOST") or '127.0.0.1'
DB_PORT = os.environ.get("DB_PORT") or 3306
DB_USER = os.environ.get("DB_USER") or 'jumpserver'
DB_PASSWORD = os.environ.get("DB_PASSWORD") or 'somepassword'
DB_NAME = os.environ.get("DB_NAME") or '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 = os.environ.get("REDIS_HOST") or '127.0.0.1'
REDIS_PORT = os.environ.get("REDIS_PORT") or 6379
REDIS_PASSWORD = os.environ.get("REDIS_PASSWORD") or ''
REDIS_DB_CELERY = os.environ.get('REDIS_DB') or 3
REDIS_DB_CACHE = os.environ.get('REDIS_DB') or 4 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()

2.8 生成数据库表结构和初始化数据

$ cd /opt/jumpserver/utils
$ bash make_migrations.sh

2.9 运行 JumpServer

$ cd /opt/jumpserver
$ ./jms start all # 后台运行使用 -d 参数./jms start all -d
# 新版本更新了运行脚本,使用方式./jms start|stop|status|restart all 后台运行请添加 -d 参数
# 运行不报错,请浏览器访问 http://你的IP:8080/ 默认账号: admin 密码: admin 页面显示不正常先不用处理,跟着教程继续操作就行,后面搭建 nginx 代理就可以正常访问了

3. 安装SSH Server和WebSocket Server:Coco

3.1 下载或 Clone 项目

$ cd /opt
$ source /opt/py3/bin/activate
$ git clone https://github.com/jumpserver/coco.git && cd coco && git checkout master

3.2 安装依赖

$ cd /opt/coco/requirements
$ yum -y install $(cat rpm_requirements.txt)
$ pip install -r requirements.txt -i https://pypi.org/simple

3.3 修改配置文件并运行

$ 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注册, 识别而已, 不能重复
# 命名标准:coco-公司/项目名,如 coco-lkt coco-fsl
# NAME = "localhost"
NAME = "coco-lkt" # 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 = 'hostname' # 登录是否支持密码认证
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://192.168.244.144:8080/terminal/terminal/)接受coco的注册,如果页面不正常可以等部署完成后再处理

4. 安装Web Terminal前端:Luna

# Luna 已改为纯前端,需要 Nginx 来运行访问
# 访问(https://github.com/jumpserver/luna/releases)下载对应版本的 release 包,直接解压,不需要编译
$ cd /opt
$ wget https://github.com/jumpserver/luna/releases/download/1.3.3/luna.tar.gz
$ tar xvf luna.tar.gz
$ chown -R root:root luna

5. 安装Windows支持组件

5.1 Docker安装 (仅针对CentOS7,CentOS6安装Docker相对比较复杂)

# 因为手动安装 guacamole 组件比较复杂,这里提供打包好的 docker 使用, 启动 guacamole
$ 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

5.2 启动 Guacamole

# 这里所需要注意的是 guacamole 暴露出来的端口是 8081,若与主机上其他端口冲突请自定义
# 修改下面 docker run 里的 JUMPSERVER_SERVER 参数,必须是外网IP,填上 Jumpserver 的 url 地址, 启动成功后去 Jumpserver 会话管理-终端管理(http://jumpserver:8080/terminal/terminal/)接受[Gua]开头的一个注册,如果页面显示不正常可以等部署完成后再处理
# 注意:这里需要修改下 http://<填写jumpserver的url地址> ,地址必须是外网生效的域名或者外网IP,否则会出错, 带宽有限, 下载时间可能有点长,可以喝杯咖啡,撩撩对面的妹子
# 不能使用 127.0.0.1 ,可以更换 jumpserver/guacamole:latest
# 安装下载
$ 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地址> \
registry.jumpserver.org/public/guacamole:latest
# Docker相关操作
$ docker ps -a # 查看当前运行或者停止的容器
$ docker start/stop 容器ID # 启动或者停止某个容器
$ docker rm 容器ID # 删除某个容器
$ docker images # 列出镜像列表
$ docker rmi 镜像ID # 删除某个镜像

6. 配置nginx

6.1 安装nginx

yum install nginx -y

6.2 配置文件,server段

server {
listen 80; # 代理端口,以后将通过此端口进行访问,不再通过8080端口 location /luna/ {
try_files $uri / /index.html;
alias /opt/luna/; # 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";
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
access_log off;
} location /guacamole/ {
proxy_pass http://localhost:8081/; # 如果guacamole安装在别的服务器,请填写它的ip
proxy_buffering off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
access_log off;
client_max_body_size 100m; # Windows 文件上传大小限制
} location / {
proxy_pass http://localhost:8080; # 如果jumpserver安装在别的服务器,请填写它的ip
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}

6.3 运行 nginx

$ nginx -t   # 确保配置没有问题, 有问题请先解决
# CentOS 7
$ systemctl start nginx
$ systemctl enable nginx

6.4 开始使用 JumpServer

6.4.1 检查应用是否已经正常运行

$ cd /opt/jumpserver
$ ./jms status # 确定jumpserver已经运行,如果没有运行请重新启动jumpserver $ cd /opt/coco
$ ./cocod status # 确定jumpserver已经运行,如果没有运行请重新启动coco # 如果安装了 Guacamole
$ docker ps -a # 检查容器是否已经正常运行,如果没有运行请重新启动Guacamole
# 如果停止运行了,就需要启动一下
$ docker start 容器ID

6.4.2 使用

服务全部启动后,访问 http://192.168.244.144,访问nginx代理的端口,不要再通过8080端口访问

默认账号: admin 密码: admin

如果部署过程中没有接受应用的注册,需要到Jumpserver 会话管理-终端管理 接受 Coco Guacamole 等应用的注册。

6.4.3 测试连接

如果登录客户端是 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 目录下

小花样

/opt/coco/coco/interactive.py

////////////////////////////////////////////////////////////////////\r
// _ooOoo_ //\r
// o8888888o //\r
// 88" . "88 //\r
// (| ^_^ |) //\r
// O\ = /O //\r
// ____/`---'\____ //\r
// .' \\\\| |// `. //\r
// / \\\\||| : |||// \ //\r
// / _||||| -:- |||||- \ //\r
// | | \\\\\ - /// | | //\r
// | \_| ''\---/'' | | //\r
// \ .-\__ `-` ___/-. / //\r
// ___`. .' /--.--\ `. . ___ //\r
// ."" '< `.___\_<|>_/___.' >'"". //\r
// | | : `- \`.;`\ _ /`;.`/ - ` : | | //\r
// \ \ `-. \_ __\ /__ _/ .-` / / //\r
// ========`-.____`-.___\_____/___.-`____.-'======== //\r
// `=---=' //\r
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ //\r
// {green}佛祖保佑 永不宕机{end} //\r
////////////////////////////////////////////////////////////////////\r\n\r

JumpServer 安装配置的更多相关文章

  1. CentOS 7下JumpServer安装及配置

    环境 系统 # cat /etc/redhat-release CentOS Linux release 7.4.1708 (Core) # uname -r 3.10.0-693.21.1.el7. ...

  2. jumpserver安装

    一. 准备 Python3 和 Python 虚拟环境  1.1 安装依赖包 yum -y install wget sqlite-devel xz gcc automake zlib-devel o ...

  3. jumpserver安装与部署

    1.简介 Jumpserver 是一款由Python编写开源的跳板机(堡垒机)系统,实现了跳板机应有的功能.基于ssh协议来管理,客户端无需安装agent.特点:  完全开源,GPL授权   Pyth ...

  4. jumpserver安装和使用

    jumpserver安装 #centos6 centos7都可用yum -y install git python-pip mysql-devel gcc automake autoconf pyth ...

  5. Hive安装配置指北(含Hive Metastore详解)

    个人主页: http://www.linbingdong.com 本文介绍Hive安装配置的整个过程,包括MySQL.Hive及Metastore的安装配置,并分析了Metastore三种配置方式的区 ...

  6. Hive on Spark安装配置详解(都是坑啊)

    个人主页:http://www.linbingdong.com 简书地址:http://www.jianshu.com/p/a7f75b868568 简介 本文主要记录如何安装配置Hive on Sp ...

  7. ADFS3.0与SharePoint2013安装配置(原创)

    现在越来越多的企业使用ADFS作为单点登录,我希望今天的内容能帮助大家了解如何配置ADFS和SharePoint 2013.安装配置SharePoint2013这块就不做具体描述了,今天主要讲一下怎么 ...

  8. Hadoop的学习--安装配置与使用

    安装配置 系统:Ubuntu14.04 java:1.7.0_75 相关资料 官网 下载地址 官网文档 安装 我们需要关闭掉防火墙,命令如下: sudo ufw disable 下载2.6.5的版本, ...

  9. redis的安装配置

    主要讲下redis的安装配置,以及以服务的方式启动redis 1.下载最新版本的redis-3.0.7  到http://redis.io/download中下载最新版的redis-3.0.7 下载后 ...

随机推荐

  1. Python 语法2

    文档字符串,这个只能是用于紧跟函数第二行的内容. 输出文档说明的部分,代码格式是 函数名称.(dot)__(双下划线)doc__(双下划线) ///////////////////////////// ...

  2. 一个http请求从用户输入网址开始到结束都发生了什么

    一个http请求从用户输入网址开始到结束都发生了什么   一.一个http请求从开始到Django后台,到结束发生了什么 通过用户输入的域名解析出IP地址 TCP/IP 三次握手 进入nginx--- ...

  3. django + 阿里云云服务器网站搭建

    最近自己用django搭了一个小网站,个人的项目挂在了github上 https://github.com/LOMOoO/tpure 预计是挂在阿里云的云服务器上运行,云服务器买好了,阿里云的域名也买 ...

  4. 两种语言实现设计模式(C++和Java)(四:适配器模式)

    参考:http://blog.jobbole.com/109381/ 将一个类的接口转换成客户希望的另外一个接口.Adapter模式使得原本由于接口不兼容而不能一起工作的那些类可以一起工作. 系统的数 ...

  5. iOS .tbd

    http://stackoverflow.com/questions/31450690/why-xcode-7-shows-tbd-instead-of-dylib http://www.jiansh ...

  6. 关于jetbrains系列产品2018.1.5以后的使用(crack)方法

    产品请一律官网下载:https://www.jetbrains.com/ 我这里以JetBrains GoLand 2018.2.1为例说明下非付费的使用方法(若资金允许,请点击https://www ...

  7. python接口测试-将运行结果写入Excel表格

    公司工作是促进学习的第一生产力!! 一个get请求的接口,我想清楚的在Excel中看到所有的数据! 带着学过H5,php觉得所有代码都很简单的自信,在公司开发的[鼓励]下开始了一上午的斗争 一个小时. ...

  8. python_ 基本语法

    一.基础知识: 1.鸡汤 摘抄至 :简明 python 教程 在人生中取得成功,与其说靠天才与机会,不如说靠专注与毅力! Python 特点:简单.易于学习(简单得语法体系).自由且开发.高级语言.跨 ...

  9. 关于修改banner信息;nginx反向代理apache应用

    本周实验 1. Linux下Apache部署一个php页面,返回http数据包中查看server信息,修改Apache 配置使server banner自定义. 2. nginx设置反向代理,代理上面 ...

  10. TEAMWORK1

    代码信息 队友:马司雨 队友项目:Prim算法生成最小生成树 codeing地址:这里 博客地址:那里 代码功能审查表 功能模块名称 Prim算法生成最小生成树 审查人 张洋 审查日期 2019.4. ...