部署 JumpServer

JumpServer Docs


JumpServer 环境要求:

硬件配置: 2个CPU核心, 4G 内存, 50G 硬盘(最低)

操作系统: Linux 发行版 x86_64

Python = 3.6.x
Mysql Server ≥ 5.6
Mariadb Server ≥ 5.5.56
Redis


极速安装

说明

全新安装的 Centos7 (7.x)
需要连接 互联网
使用 root 用户执行

资产数量不多,或者测试体验的用户请使用本脚本快速部署
如果资产规模较大,请参考 分布式部署 文档

注意: 对系统进行任何修改均可能导致安装失败,推荐在安装完成后再进行调优

一键安装 JumpServer

curl -sSL https://github.com/jumpserver/jumpserver/releases/download/2.0.1/quick_start.sh | sh

下载

下载文件

cd /opt
yum -y install wget git
git clone --depth=1 https://github.com/jumpserver/setuptools.git
cd setuptools
cp config_example.conf config.conf
vi config.conf
配置文件说明, 注意不能使用纯数字字符串, 如果不知道用途请勿修改
# 以下设置默认情况下不需要修改

# 需要安装的版本
Version=2.0.0

# Jms 加密配置
SECRET_KEY=
BOOTSTRAP_TOKEN=

# 数据库 配置, 如果 数据库 安装在其他的服务器, 请修改下面设置
DB_HOST=127.0.0.1
DB_PORT=3306
DB_USER=jumpserver
DB_PASSWORD=
DB_NAME=jumpserver

# Redis 配置, 如果 Redis 安装在其他的服务器, 请修改下面设置
REDIS_HOST=127.0.0.1
REDIS_PORT=6379
REDIS_PASSWORD=

# 服务端口设置, 如果云服务器未备案请修改 http_port 端口为其他端口
http_port=80
ssh_port=2222

# 服务安装目录
install_dir=/opt

Server_IP=`ip addr | grep 'state UP' -A2 | grep inet | egrep -v '(127.0.0.1|inet6|docker)' | awk '{print $2}' | tr -d "addr:" | head -n 1 | cut -d / -f1`
Docker_IP=`ip addr | grep docker.* | grep inet | awk '{print $2}' | head -n 1`

安装

Install

./jmsctl.sh install

帮助

Help

./jmsctl.sh -h

升级

Upgrade

cd /opt/setuptools
git pull
./jmsctl.sh upgrade

详细安装步骤

1. 安装 Python3.6 MySQL Redis

数据库字符集要求:

create database jumpserver default charset 'utf8' collate 'utf8_bin';

2. 创建 Python 虚拟环境

python3.6 -m venv /opt/py3

3. 载入 Python 虚拟环境

source /opt/py3/bin/activate

每次操作 JumpServer 都需要先载入 py3 虚拟环境

部分系统可能会提示 source: not found, 可以使用 . 代替 source

4. 获取 JumpServer 代码

cd /opt && \
wget -O jumpserver.tar.gz https://github.com/jumpserver/jumpserver/archive/2.0.1.tar.gz
tar xf jumpserver.tar.gz
mv jumpserver-2.0.1 jumpserver

5. 安装编译环境依赖

cd /opt/jumpserver/requirements
根据当前系统, 选择对应的文件执行即可
pip install wheel && \
pip install --upgrade pip setuptools && \
pip install -r requirements.txt
确保已经载入 py3 虚拟环境, 中间如果遇到报错一般是依赖包没装全, 可以通过 搜索引擎 解决

6. 修改配置文件

cd /opt/jumpserver && \
cp config_example.yml config.yml && \
vi config.yml
注意不能使用纯数字字符串, 可以参考此模版

7. 启动 JumpServer

cd /opt/jumpserver
./jms start
确保已经载入 py3 虚拟环境
可以 -d 参数在后台运行

8. 正常部署 KoKo 组件

cd /opt && \
wget https://github.com/jumpserver/koko/releases/download/2.0.1/koko-master-linux-amd64.tar.gz
tar -xf koko-master-linux-amd64.tar.gz && \
chown -R root:root kokodir && \
cd kokodir
cp config_example.yml config.yml && \
vi config.yml
BOOTSTRAP_TOKEN 需要从 jumpserver/config.yml 里面获取, 保证一致
./koko  
可以 -d 参数在后台运行

8.1. Docker 部署 KoKo 组件

如果前面已经正常部署了 KoKo, 可以跳过此步骤

例:

docker run --name jms_koko -d \
  -p 2222:2222 \
  -p 127.0.0.1:5000:5000 \
  -e CORE_HOST=http://192.168.244.144:8080 \
  -e BOOTSTRAP_TOKEN=zxffNymGjP79j6BN \
  -e LOG_LEVEL=ERROR \
  --restart=always \
  jumpserver/jms_koko:2.0.1

9. 正常部署 Guacamole 组件

建议使用 Docker 部署 Guacamole 组件 , 部分环境可能无法正常编译安装

cd /opt && \
wget -O /opt/guacamole.tar.gz https://github.com/jumpserver/guacamole/archive/2.0.1.tar.gz
tar -xf guacamole.tar.gz && \
mv docker-guacamole-2.0.1 guacamole && \
cd /opt/guacamole && \
tar -xf guacamole-server-1.0.0.tar.gz && \
tar -xf ssh-forward.tar.gz -C /bin/ && \
chmod +x /bin/ssh-forward
cd /opt/guacamole/guacamole-server-1.0.0
根据 Guacamole官方文档 文档安装对应的依赖包
autoreconf -fi && \
./configure --with-init-dir=/etc/init.d && \
make && \
make install
需要先在当前环境配置好 Java
mkdir -p /config/guacamole /config/guacamole/extensions /config/guacamole/record /config/guacamole/drive && \
chown daemon:daemon /config/guacamole/record /config/guacamole/drive && \
cd /config
访问 此处 下载最新的 Tomcat9
tar -xf apache-tomcat-9.0.35.tar.gz && \
mv apache-tomcat-9.0.35 tomcat9 && \
rm -rf /config/tomcat9/webapps/* && \
sed -i 's/Connector port="8080"/Connector port="8081"/g' /config/tomcat9/conf/server.xml && \
echo "java.util.logging.ConsoleHandler.encoding = UTF-8" >> /config/tomcat9/conf/logging.properties && \
ln -sf /opt/guacamole/guacamole-1.0.0.war /config/tomcat9/webapps/ROOT.war && \
ln -sf /opt/guacamole/guacamole-auth-jumpserver-1.0.0.jar /config/guacamole/extensions/guacamole-auth-jumpserver-1.0.0.jar && \
ln -sf /opt/guacamole/root/app/guacamole/guacamole.properties /config/guacamole/guacamole.properties

设置 Guacamole 环境

export JUMPSERVER_SERVER=http://127.0.0.1:8080
echo "export JUMPSERVER_SERVER=http://127.0.0.1:8080" >> ~/.bashrc
export BOOTSTRAP_TOKEN=zxffNymGjP79j6BN
echo "export BOOTSTRAP_TOKEN=zxffNymGjP79j6BN" >> ~/.bashrc
export JUMPSERVER_KEY_DIR=/config/guacamole/keys
echo "export JUMPSERVER_KEY_DIR=/config/guacamole/keys" >> ~/.bashrc
export GUACAMOLE_HOME=/config/guacamole
echo "export GUACAMOLE_HOME=/config/guacamole" >> ~/.bashrc
export GUACAMOLE_LOG_LEVEL=ERROR
echo "export GUACAMOLE_LOG_LEVEL=ERROR" >> ~/.bashrc
export JUMPSERVER_ENABLE_DRIVE=true
echo "export JUMPSERVER_ENABLE_DRIVE=true" >> ~/.bashrc
环境变量说明

启动 Guacamole

/etc/init.d/guacd start
sh /config/tomcat9/bin/startup.sh

9.1 Docker 部署 Guacamole 组件

如果前面已经正常部署了 Guacamole, 可以跳过此步骤

docker run --name jms_guacamole -d \
  -p 127.0.0.1:8081:8080 \
  -e JUMPSERVER_SERVER=http://<Jumpserver_url> \
  -e BOOTSTRAP_TOKEN=<Jumpserver_BOOTSTRAP_TOKEN> \
  -e GUACAMOLE_LOG_LEVEL=ERROR \
  jumpserver/jms_guacamole:<Tag>
<Jumpserver_url> 为 JumpServer 的 url 地址, <Jumpserver_BOOTSTRAP_TOKEN> 需要从 jumpserver/config.yml 里面获取, 保证一致, <Tag> 是版本

例:

docker run --name jms_guacamole -d \
  -p 127.0.0.1:8081:8080 \
  -e JUMPSERVER_SERVER=http://192.168.244.144:8080 \
  -e BOOTSTRAP_TOKEN=abcdefg1234 \
  -e GUACAMOLE_LOG_LEVEL=ERROR \
  jumpserver/jms_guacamole:2.0.1

10. 下载 Lina 组件

cd /opt
wget https://github.com/jumpserver/lina/releases/download/2.0.1/lina.tar.gz
tar -xf lina.tar.gz
chown -R nginx:nginx lina

11. 下载 Luna 组件

cd /opt
wget https://github.com/jumpserver/luna/releases/download/2.0.1/luna.tar.gz
tar -xf luna.tar.gz
chown -R nginx:nginx luna

12. 配置 Nginx 整合各组件

参考 官方文档 安装最新的稳定版 nginx

echo > /etc/nginx/conf.d/default.conf
vi /etc/nginx/conf.d/jumpserver.conf
server {
    listen 80;

    client_max_body_size 100m;  # 录像及文件上传大小限制

    location /ui/ {
        try_files uri / /index.html;
        alias /opt/lina/;
    }

    location /luna/ {
        try_filesuri / /index.html;
        alias /opt/luna/;  # luna 路径, 如果修改安装目录, 此处需要修改
    }

    location /media/ {
        add_header Content-Encoding gzip;
        root /opt/jumpserver/data/;  # 录像位置, 如果修改安装目录, 此处需要修改
    }

    location /static/ {
        root /opt/jumpserver/data/;  # 静态资源, 如果修改安装目录, 此处需要修改
    }

    location /koko/ {
        proxy_pass       http://localhost:5000;
        proxy_buffering off;
        proxy_http_version 1.1;
        proxy_set_header Upgrade http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header X-Real-IPremote_addr;
        proxy_set_header Host host;
        proxy_set_header X-Forwarded-Forproxy_add_x_forwarded_for;
        access_log off;
    }

    location /guacamole/ {
        proxy_pass       http://localhost:8081/;
        proxy_buffering off;
        proxy_http_version 1.1;
        proxy_set_header Upgrade http_upgrade;
        proxy_set_header Connectionhttp_connection;
        proxy_set_header X-Real-IP remote_addr;
        proxy_set_header Hosthost;
        proxy_set_header X-Forwarded-For proxy_add_x_forwarded_for;
        access_log off;
    }

    location /ws/ {
        proxy_set_header X-Real-IPremote_addr;
        proxy_set_header Host host;
        proxy_set_header X-Forwarded-Forproxy_add_x_forwarded_for;
        proxy_pass http://localhost:8070;
        proxy_http_version 1.1;
        proxy_buffering off;
        proxy_set_header Upgrade http_upgrade;
        proxy_set_header Connection "upgrade";
    }

    location /api/ {
        proxy_pass http://localhost:8080;
        proxy_set_header X-Real-IPremote_addr;
        proxy_set_header Host host;
        proxy_set_header X-Forwarded-Forproxy_add_x_forwarded_for;
    }

    location /core/ {
        proxy_pass http://localhost:8080;
        proxy_set_header X-Real-IP remote_addr;
        proxy_set_header Hosthost;
        proxy_set_header X-Forwarded-For proxy_add_x_forwarded_for;
    }

    location / {
        rewrite ^/(.*) /ui/$1 last;
    }
}
nginx -t
nginx -s reload

13. 开始使用 JumpServer

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

服务全部启动后, 访问 JumpServer 服务器 nginx 代理的 80 端口, 不要通过8080端口访问 默认账号: admin 密码: admin

Jumpserver 快速入门

以下操作均在 Web 页面完成,请使用 admin 用户登陆,默认密码 admin

一、系统设置

1.1 基本设置

Warning

当前站点URL 不设置的话,邮件收到的地址为 http://localhost 开头
Email主题前缀 邮件的标题,比如 [JMS] 收到的邮件会是 [jms]创建用户成功 这样的

用户向导URL 用户首次登陆可以看到此 超链接,可以忽略不设置

1.2 邮件设置

必须设置才能使用与邮件相关的功能

不可以同时勾选 使用SSL  使用TLS

SMTP主机 输入你或者你服务商提供的 smtp 服务器, 格式:smtp.qq.com
SMTP端口 通常是 25,推荐使用更安全的 465 或者 587
SMTP账号 通常是 user@domain.com
SMTP密码 输入对应账户的密码,注意:每次测试都需要重新输入密码
发送账号SMTP账户 保持一致

测试收件人 测试连接时一定要输入

二、资产管理

准备两个测试资产和一个数据库来验证功能

+--------------+-----------------+------------+------------+---------------+---------------+
|      IP      |    Host name    |    Port    |   System   |  Admin User   |    Password   |
+==============+=================+============+============+===============+===============+
| 172.16.80.11 |    test_ssh01   |     22     |  Centos 7  |      root     |  Test2020.L   |
+--------------+-----------------+------------+------------+---------------+---------------+
| 172.16.80.21 |    test_rdp01   |    3389    | Windows 10 | administrator |  Test2020.W   |
+--------------+-----------------+------------+------------+---------------+---------------+
| 172.16.80.31 |   test_mysql01  |    3306    |   Mysql 5  |      root     |  Test2020.M   |
+--------------+-----------------+------------+------------+---------------+---------------+

Windows 资产先进行 Windows SSH 设置

Mysql Server 需要授权 core 和 koko 的远程访问的权限

mysql -uroot
grant all on *.* to 'root'@'%' identified by 'Test2020.M';
flush privileges;

2.1 编辑资产树

根节点 Default 不能重名, 右击节点可以添加、删除和重命名节点, 以及进行资产相关的操作

说明

点击页面左侧的 资产管理 - 资产列表
先在根节点 Default 右键新建 SSH ServerRDP Server 两个节点

2.2 创建管理用户

点击页面左侧的 资产管理 - 新建管理用户 创建两个管理用户, 管理用户的内容就是上面表单的 Admin UserPassword

名称不能重名, 密码或者密钥二选一即可, 一些资产不允许通过 密码 认证可以改用 私钥 认证

名称` 172.16.80.11_root
`用户名` root
`密码` Test2020.L
点击 `保存

再创建 Windows 资产的 管理用户
名称 172.16.80.21_administrator
用户名 administrator
密码 Test2020.W
点击 保存

2.3 创建资产

点击页面左侧的 资产管理 - 资产列表 - 创建资产 把两个资产导入

主机名不能重名

主机名` test_ssh01
`IP` 172.16.80.11
`系统平台` Linux
`协议组` ssh 22
`管理用户` 172.16.80.11_root
`节点` Default / SSH Server
点击 `保存

再创建 Windows 资产, 注意协议组我们需要选择 sshrdp, 否则无法获取 Windows 资产的状态及硬件信息
主机名 172.16.80.21_administrator
IP 172.16.80.21
系统平台 Windows2016
协议组 rdp 3389 / ssh 22
管理用户 test_test_rdp01_administrator
节点 Default / RDP Server
点击 保存

测试资产连接提示
  1. 资产创建信息填写好保存之后隔几秒钟时间刷新一下网页, ssh 协议资产的可连接图标会显示 绿色, 且 硬件信息会显示出来
  2. 如果 可连接 的图标是 黄色 或者 红色 , 可以点击 资产  名称,在右侧 快速修改 - 测试可连接性 点击 测试 按钮, 根据错误提示处理
  3. 被连接 Linux 资产需要 python 组件, 且版本大于等于 2.6, Ubuntu 等资产默认不允许 root 用户远程 ssh 登录, 请自行处理, Windows 资产需要手动安装 OpenSSH Server
  4. 如果资产不能正常连接, 请检查 管理用户 的 用户名  密码 是否正确以及该 管理用户 是否能使用 SSH JumpServer 主机正确登录到资产主机上

2.3.1 创建数据库应用

击页面左侧的 应用管理 - 数据库应用 - 创建数据库应用 创建 mysql 数据库

名称 test_mysql01
类型 MySQL
主机 172.16.80.31
端口 3306

数据库 选项可以留空, 如果是某些特定用户, 只允许访问指定的数据库, 这里指定数据库名称即可

2.4 创建系统用户

+--------------+------------+---------------+---------------+--------------+--------------+-------------+
|      IP      |   System   |  System User  |    Password   |     Group    |     Sudo     |  Sftp Root  |
+==============+============+===============+===============+==============+==============+=============+
| 172.16.80.11 |  Centos 7  |   testssh01   |  random pass  |              |      ALL     |      /      |
+--------------+------------+---------------+---------------+--------------+--------------+-------------+
| 172.16.80.21 | Windows 10 |   testrdp01   |  random pass  |     Users    |              |             |
+--------------+------------+---------------+---------------+--------------+--------------+-------------+
| 172.16.80.23 |   Mysql 5  |      root     |  Test2020.M   |              |              |             |
+--------------+------------+---------------+---------------+--------------+--------------+-------------+
系统用户提示

点击页面左侧的 资产管理 - 系统用户 - 创建系统用户 创建两个系统用户

名称` test_ssh01_测试系统用户
`登录模式` 自动登陆
`用户名` testssh01
`协议` ssh
`Sudo` ALL `SFTP根路径` /
其他选项默认, 点击 `保存

再创建 Windows 系统用户
名称 test_rdp01_测试系统用户
登录模式 自动登陆
用户名 testrdp01
协议 rdp
其他选项默认, 点击 保存

创建 MySQL 系统用户
名称 test_mysql01_测试系统用户
登录模式 自动登陆
用户名 root
协议 mysql
密码 Test2020.M
其他选项默认, 点击 保存

三、创建授权规则

3.1 为用户分配资产

+--------------+------------+---------------+-----------------+
|      IP      |   System   |  System User  | JumpServer User |
+==============+============+===============+=================+
| 172.16.80.11 |  Centos 7  |   testssh01   |      admin      |
+--------------+------------+---------------+-----------------+
| 172.16.80.21 | Windows 10 |   testrdp01   |      admin      |
+--------------+------------+---------------+-----------------+
| 172.16.80.31 |  Mysql 5   |      root     |      admin      |
+--------------+------------+---------------+-----------------+

点击页面左侧的 授权管理 - 资产授权 - 创建授权规则 创建两个授权

名称` test_ssh01_测试授权
`用户` Administrator(admin)
`资产` test_ssh01(172.16.80.11)
`系统用户` test_ssh01_测试系统用户(testssh01)
`有效期` 时间自行定义, 用户只能在有效期时间内连接资产
修改完成后点击 `保存

再创建 Windows 授权
名称 test_rdp01_测试授权
用户 Administrator(admin)
资产 test_rdp01(172.16.80.21)
系统用户 test_rdp01_测试系统用户(testrdp01)
修改完成后点击 保存

资产授权提示

3.1.1 为用户分配数据库应用

点击页面左侧的 授权管理 - 数据库应用 - 创建授权规则 创建数据库授权

名称` test_mysql01_测试授权
`用户` Administrator(admin)
`数据库应用` test_mysql01
`系统用户` test_mysql01_测试系统用户(root)
修改完成后点击 `保存

四、用户登录

登录 JumpServer

点击页面左侧的 会话管理 - Web终端 用户只能看到自己被管理员授权了的 资产 , 如果登录后无资产, 请联系管理员进行确认

连接资产

在我的资产点击资产右边的 连接 快速连接资产
也可以点击左侧栏的 Web终端 点击 资产 名字, 就连上资产了
如果显示连接 超时, 请参考 FAQ 文档进行处理

断开资产

点击页面顶部的 Server 按钮会弹出选个选项, 第一个断开所选的连接, 第二个断开所有连接
也可以直接点资产小窗口的 X , SSH 会话也可以输入 exit 来退出
直接关闭页面也可以, 但是不推荐

文件管理

点击 文件管理
先在左边选择资产, 目前只支持自动登录的 SSH 协议 资产
也可以使用 sftp 方式进行 文件管理


Copyright © 2009 - Now . XPBag.com . All rights Reserved.
夜心的小站 » 部署 JumpServer

提供最优质的资源集合

立即查看 了解详情