环境

系统: CentOS 7

IP: 192.168.244.144

关闭 selinux 和防火墙

# CentOS 7

$ setenforce 0  # 可以设置配置文件永久关闭

$ systemctl stop iptables.service

$ 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

# CentOS6

$ setenforce 0

$ service iptables stop

# 修改字符集,否则可能报 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/sysconfig/i18n

一. 准备 Python3 和 Python 虚拟环境

1.1 安装依赖包

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

Yum 加速设置请参考 <http://mirrors.163.com/.help/centos.html>

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 && make && make install

# 这里必须执行编译安装,否则在安装 Python 库依赖时会有麻烦...

1.3 建立 Python 虚拟环境

因为 CentOS 6/7 自带的是 Python2,而 Yum 等工具依赖原来的 Python,为了不扰乱原来的环境我们来使用 Python 虚拟环境

$ cd /opt

$ python3 -m venv py3

$ source /opt/py3/bin/activate

# 看到下面的提示符代表成功,以后运行 Jumpserver 都要先运行以上 source 命令,以下所有命令均在该虚拟环境中运行

(py3) [root@localhost py3]

二. 安装 Jumpserver 1.0.0

2.1 下载或 Clone 项目

项目提交较多 git clone 时较大,你可以选择去 Github 项目页面直接下载zip包。

$ cd /opt/

$ git clone --depth=1 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参数,因为镜像上可能没有最新的包,如果没有任何报错请继续

Pip 加速设置请参考 <https://segmentfault.com/a/1190000011875306>

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

$ yum -y install redis

$ systemctl start redis

# centos6

$ service redis start

2.5 安装 MySQL

本教程使用 Mysql 作为数据库,如果不使用 Mysql 可以跳过相关 Mysql 安装和配置

# centos7

$ yum -y install mariadb mariadb-devel mariadb-server # centos7下安装的是mariadb

$ systemctl enable mariadb

$ systemctl start mariadb

# centos6

$ yum -y install mysql mysql-devel mysql-server

$ chkconfig mysqld on

$ service mysqld start

2.6 创建数据库 Jumpserver 并授权

$ mysql

> create database jumpserver default charset 'utf8';

> grant all on jumpserver.* to 'jumpserver'@'127.0.0.1' identified by 'somepassword';

2.7 修改 Jumpserver 配置文件

$ cd /opt/jumpserver

$ cp config_example.py config.py

$ vi config.py

# 我们计划修改 DevelopmentConfig 中的配置,因为默认 Jumpserver 使用该配置,它继承自 Config

注意: 配置文件是 Python 格式,不要用 TAB,而要用空格

class DevelopmentConfig(Config):

DEBUG = True

DB_ENGINE = 'mysql'

DB_HOST = '127.0.0.1'

DB_PORT = 3306

DB_USER = 'jumpserver'

DB_PASSWORD = 'somepassword'

DB_NAME = 'jumpserver'

...

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://192.168.244.144:8080/ 页面显示不正常先不用处理,需要搭建 nginx 代理就可以正常访问了

附上重启的方法

$ ./jms restart

三. 安装 SSH Server 和 WebSocket Server: Coco

3.1 下载或 Clone 项目

新开一个终端,连接测试机,别忘了 source /opt/py3/bin/activate

$ 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

3.3 查看配置文件并运行

$ cd /opt/coco

$ cp conf_example.py conf.py  # 如果 coco 与 jumpserver 分开部署,请手动修改 conf.py

$ ./cocod start  # 后台运行使用 -d 参数./cocod start -d

# 新版本更新了运行脚本,使用方式./cocod start|stop|status|restart  后台运行请添加 -d 参数

后面设置好 nginx 后,记得去 Jumpserver 管理后台-会话管理-终端管理(http://192.168.244.144:8080/terminal/terminal/)接受 Coco 的注册

Coco version 1.0.0, more see https://www.jumpserver.org

Starting ssh server at 0.0.0.0:2222

Quit the server with CONTROL-C.

3.4 测试连接

$ ssh -p2222 admin@192.168.244.144

密码: admin

如果是用在 Windows 下,Xshell Terminal 登录语法如下

$ssh admin@192.168.244.144 2222

密码: admin

如果能登陆代表部署成功

四. 安装 Web Terminal 前端: Luna

Luna 已改为纯前端,需要 Nginx 来运行访问

访问(https://github.com/jumpserver/luna/releases)下载对应版本的 release 包,直接解压,不需要编译

4.1 解压 Luna

$ pwd

/opt/

$ wget https://github.com/jumpserver/luna/releases/download/v1.0.0/luna.tar.gz

$ tar xvf luna.tar.gz

$ ls /opt/luna

...

五. 安装 Windows 支持组件(如果不需要管理 windows 资产,可以直接跳过这一步)

因为手动安装 guacamole 组件比较复杂,这里提供打包好的 docker 使用, 启动 guacamole

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

$ yum remove docker-latest-logrotate  docker-logrotate  docker-selinux dockdocker-engine

$ yum install docker-ce

$ yum install -y yum-utils   device-mapper-persistent-data   lvm2

$ yum-config-manager     --add-repo     https://download.docker.com/linux/centos/docker-ce.repo

$ yum-config-manager --enable docker-ce-edge

$ yum-config-manager --enable docker-ce-test

$ yum-config-manager --disable docker-ce-edge

$ yum install docker-ce

$ systemctl start docker

$ systemctl status docker

5.2 启动 Guacamole

这里所需要注意的是 guacamole 暴露出来的端口是 8081,若与主机上其他端口冲突请自定义

修改 JUMPSERVER_SERVER 环境变量的配置,填上 Jumpserver 的内网地址, 启动成功后去 Jumpserver 会话管理-终端管理(http://192.168.244.144:8080/terminal/terminal/)接受[Gua]开头的一个注册

# 注意:这里一定要改写一下本机的IP地址, 否则会出错, 带宽有限, 下载时间可能有点长,可以喝杯咖啡,撩撩对面的妹子

$ 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://<填写本机的IP地址>:8080 \

registry.jumpserver.org/public/guacamole:1.0.0

六. 配置 Nginx 整合各组件

6.1 安装 Nginx 根据喜好选择安装方式和版本

$ yum -y install nginx

6.2 准备配置文件 修改 /etc/nginx/conf.d/jumpserver.conf

内容如下:

$ vim /etc/nginx/nginx.conf

... 省略

# 把默认server配置块改成这样

server {

listen 80;

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;

}

location / {

proxy_pass http://localhost:8080;  # 如果jumpserver安装在别的服务器,请填写它的ip

}

}

... 省略

6.3 运行 Nginx

nginx -t   # 确保配置没有问题, 有问题请先解决

# CentOS 7

$ systemctl start nginx

$ systemctl enable nginx

# CentOS 6

$ service nginx start

$ chkconfig nginx on

6.4 访问 http://192.168.244.144

默认账号: admin 密码: admin

到管理后台-会话管理-终端管理 接受 Coco Guacamole 等应用的注册

搭建jumpserver堡垒机的更多相关文章

  1. 使用Docker搭建Jumpserver堡垒机

    使用Docker搭建Jumpserver堡垒机 1.环境准备 操作系统:CentOS 7.6.1810 软件源:阿里云镜像 #内核版本(Docker 要求 CentOS 系统的内核版本高于 3.10) ...

  2. 基于Docker搭建Jumpserver堡垒机操作实践

    一.背景 笔者最近想起此前公司使用过的堡垒机系统,觉得用的很方便,而现在的公司并没有搭建此类系统,想着以后说不定可以用上:而且最近也有点时间,因此来了搭建堡垒机系统的兴趣,在搭建过程中参考了比较多的文 ...

  3. 基于docker搭建jumpserver堡垒机

    一.环境信息 1.jumpserver 192.168.137.129 CentOS6.4   kernel版本为 3.10.5-3.el6.x86_64 2.客户机 dev01-04 3.docke ...

  4. jumpserver 堡垒机环境搭建(图文详解)

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

  5. jumpserver 堡垒机环境搭建(图文具体解释)

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

  6. 【转】jumpserver 堡垒机环境搭建(图文详解)

    jumpserver 堡垒机环境搭建(图文详解)   摘要: Jumpserver 是一款由python编写开源的跳板机(堡垒机)系统,实现了跳板机应有的功能.基于ssh协议来管理,客户端无需安装ag ...

  7. jumpserver 堡垒机环境搭建

    jumpserver 堡垒机环境搭建(图文详解) https://blog.csdn.net/my_bai/article/details/62226474   http://docs.jumpser ...

  8. jumpserver堡垒机web终端支持复制粘贴功能

    公司最近内部搭建了一个jumpserver堡垒机,但是web终端连接Windows时候没法复制粘贴文字文本 然后找了一下jumpserver官方说明没找到相应的说明,但是知道是guacamole这个组 ...

  9. JumpServer 堡垒机 指南

    堡垒机介绍 在一个特定网络环境下,为了保障网络和数据不受外界入侵和破坏,而运用各种技术手段实时收集和监控网络环境中每一个组成部分的系统状态.安全事件.网络活动,以便集中报警.及时处理及审计定责.    ...

随机推荐

  1. Python之模拟职场人生游戏

    题目:模拟人生 要求:1.至少有两个角色 2.玩的过程中,有冲突 3.根据不同的交互,产生不同的行为. 4.一定要用到面向对象语法和思想 1.解题思路 创建一个类,赋予角色不同的方法,使用面向对象思想 ...

  2. C过程思想,根据需求写方法就行

     实现的方法有多种 Comprehensive orientate 2017/10/27 13:25:07 C过程思想,根据需求写方法就行  

  3. 企业短信通 C# HTTP接口 发送短信

    /* 功能: 企业短信通 C# HTTP接口 发送短信 修改日期: 2014-09-01 说明: http://api.cnsms.cn/?ac=send&uid=用户账号&pwd=M ...

  4. iOS坑爹的could not find any information for class named xxx

    关掉项目也无法解决,最后把文件delete掉,然后选“Remove Reference”,这样就不会真正删除文件.接着选“File -> Add Files to ...”添加回来就可以了.

  5. Priceless Notes

    [Priceless Notes] 1.人类对价格的绝对值没有准确的判断,但是价格或物体的相对值有较准确的判断. 2.物理强度与主观体验的关联成幂曲线.如60瓦的灯会让人觉得亮,但要让人觉得2倍亮的话 ...

  6. Reporting Service中配置oracle 数据连接

    一.安装配置报表服务器 数据源 1.安装oracle客户端32位“Oracle - OraClient11g_home1_32bit” 2.配置监听及tnsnames.ora 3.配置ODBC 添加一 ...

  7. codeforce 459 DIV2 D题

    题意   在一个DAG上面有N个点M条边,每一条边上都有一个小写字母.两个人Max and Lucas 每个人一颗棋子,两个人轮流行棋,当前这一步选择的路上面的字母必须大于等于上一步路上面的字母,当轮 ...

  8. 【总结整理】word使用技巧

    Tab+Enter,在编过号以后,会自动编号段落 Ctrl + D调出字体栏,配合Tab+Enter全键盘操作吧 Ctrl + L 左对齐, Ctrl + R 右对齐, Ctrl + E 居中 Ctr ...

  9. HtmlHelper扩展

    扩展 HtmlHelper类 public static class MyHtmlHelper { //扩展方法 //静态类,静态方法,this关键字 //调用方法<%=Html.MyLabel ...

  10. C#获取当前站点的根地址

    /// <summary> /// 得到当前网站的根地址 /// </summary> /// <returns></returns> protecte ...