zoukankan      html  css  js  c++  java
  • JumpServer的Docker部署实战案例

    JumpServer的Docker部署实战案例

              JumpServer的Docker部署实战案例

                                  作者:尹正杰

    版权声明:原创作品,谢绝转载!否则将追究法律责任。

     

     

     

    一.JumpServer概述

    1>.什么是JumpServer

    复制代码
      JumpServer是全球首款完全开源的堡垒机, 使用GNU GPL v2.0开源协议, 是符合4A的专业运维审计系统。
    
      JumpServer使用Python/Django进行开发, 遵循Web 2.0规范, 配备了业界领先的Web Terminal解决方案, 交互界面美观、用户体验好。
    
      JumpServer采纳分布式架构, 支持多机房跨区域部署, 中心节点提供API, 各机房部署登录节点, 可横向扩展、无并发访问限制。
    
      JumpServer现已支持管理 SSH、Telnet、RDP、VNC 协议资产。
    
    
      温馨提示(4A机制如下所示):
        身份认证(Authentication):
          支持LDAP/AD,支持OpenID,支持MFA等。
    
        账号管理(Account):
          支持账号集中管理、密码统一管理、资产用户收集等。
    
        授权控制(Authorization):
          支持资产授权、应用授权、动作授权、时间授权、特权授权等。
    
        安全审计(Audit):
          支持操作审计、会话审计、录像审计、指令审计和文件传输审计等。
    复制代码

    2>.JumpServer的特点

    复制代码
      开源
        零门槛,线上快速获取和安装
    
      分布式
        轻松支持大规模并发访问
    
      云端存储
        审计录像云端存储,永不丢失
     
      无插件
        仅需浏览器,极致的Web Terminal使用体验
    
      多云支持
        一套系统,同时管理不同云上面的资产
    
      多租户
        一套系统,多个子公司和部门同时使用
    复制代码

    3>.博主推荐阅读

      官网地址:
        https://jumpserver.org/
    
      官方文档:
        https://jumpserver.readthedocs.io/zh/master/

     

    二.JumpServer环境准备

    1>.JumpServer的部署方式说明

    复制代码
      不得不说JumpServer官方提供的部署方式真的非常Nice(其实我内心想说的是花里胡哨)。不过官网推荐首次安装的用户使用"极速安装"或者"docker 快速部署"其它的部署文档需要非常强的动手能力, 部署过程中你会面临各种各样的问题。
        极速部署:
          https://jumpserver.readthedocs.io/zh/master/install/setup_by_fast/
        Docker部署:
          https://jumpserver.readthedocs.io/zh/master/install/docker_install/
        标准部署:
          https://jumpserver.readthedocs.io/zh/master/install/step_by_step/
        分布式部署:
          https://jumpserver.readthedocs.io/zh/master/install/setup_by_prod/
        ansible部署:
          https://jumpserver.readthedocs.io/zh/master/install/ansible_install/
        卸载文档:
          https://jumpserver.readthedocs.io/zh/master/install/uninstall/
    
      博主推荐阅读:
        https://jumpserver.readthedocs.io/zh/master/admin-guide/quick_start/
        https://jumpserver.readthedocs.io/zh/master/user-guide/assets/user-asset/
    复制代码

    2>.安装docker环境

      博主推荐阅读:
        CemtOS环境:
          https://www.cnblogs.com/yinzhengjie/p/12178843.html
    
        Ubuntu环境:
          https://www.cnblogs.com/yinzhengjie/p/12182645.html

    3>.安装数据库

      博主推荐阅读:
        MySQL/MariaDB数据库安装:
          https://www.cnblogs.com/yinzhengjie/p/11733897.html
    
        Redis数据库安装:
          https://www.cnblogs.com/yinzhengjie/p/10555893.html

     

    三.基于Docker方式快速部署JumpServer

    1>.下载JumpServer镜像到本地(方便启动镜像)

     [root@yinzhengjie.com ~]# docker pull jumpserver/jms_all:latest

    2>.配置MysSQL数据库配置

    复制代码
    [root@yinzhengjie.com ~]# mysql
    Welcome to the MariaDB monitor.  Commands end with ; or g.
    Your MariaDB connection id is 17
    Server version: 5.5.65-MariaDB MariaDB Server
    
    Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
    
    Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
    
    MariaDB [(none)]> 
    MariaDB [(none)]> create database jumpserver default charset 'utf8' collate 'utf8_bin';                #创建数据库
    Query OK, 1 row affected (0.00 sec)
    
    MariaDB [(none)]> 
    MariaDB [(none)]> CREATE USER jumpserver@'%' IDENTIFIED BY 'yinzhengjie';                         #创建用户
    Query OK, 0 rows affected (0.00 sec)
    
    MariaDB [(none)]>
    MariaDB [(none)]> GRANT ALL ON jumpserver.* TO jumpserver@'%';                               #为创建的用户授权已创建的jumpserver数据库所有权限。
    Query OK, 0 rows affected (0.00 sec)
    
    MariaDB [(none)]> 
    MariaDB [(none)]> grant all on jumpserver.* to 'jumpserver'@'yinzhengjie.com' identified by 'yinzhengjie';     #如果执行上述命令本机如无法正常登录,执行该命令就好使了。
    Query OK, 0 rows affected (0.00 sec)
    
    MariaDB [(none)]> 
    MariaDB [(none)]> QUIT
    Bye
    [root@yinzhengjie.com ~]# 
    复制代码
     [root@yinzhengjie.com ~]# mysql -ujumpserver -pyinzhengjie -h 172.200.1.254                      #测试授权用户是否有权限连接

    3>.配置Redis数据库

    复制代码
    [root@yinzhengjie.com ~]# hostname -i
    172.200.1.254
    [root@yinzhengjie.com ~]# 
    [root@yinzhengjie.com ~]# grep ^requirepass /etc/redis.conf 
    requirepass yinzhengjie
    [root@yinzhengjie.com ~]# 
    [root@yinzhengjie.com ~]# grep ^bind /etc/redis.conf 
    bind yinzhengjie.com
    [root@yinzhengjie.com ~]# 
    [root@yinzhengjie.com ~]# systemctl restart redis
    [root@yinzhengjie.com ~]# 
    [root@yinzhengjie.com ~]# ss -ntl
    State      Recv-Q Send-Q                                         Local Address:Port                                                        Peer Address:Port              
    LISTEN     0      50                                                         *:3306                                                                   *:*                  
    LISTEN     0      511                                            172.200.1.254:6379                                                                   *:*                  
    LISTEN     0      128                                                        *:22                                                                     *:*                  
    LISTEN     0      128                                                       :::22                                                                    :::*                  
    [root@yinzhengjie.com ~]# 
    [root@yinzhengjie.com ~]# 
    复制代码

    4>.Linux生成随机加密秘钥

    复制代码
    [root@yinzhengjie.com ~]# vim random_encryption.sh
    [root@yinzhengjie.com ~]# 
    [root@yinzhengjie.com ~]# cat random_encryption.sh
    if [ ! "$SECRET_KEY" ]; then
      SECRET_KEY=`cat /dev/urandom | tr -dc A-Za-z0-9 | head -c 50`;
      echo "SECRET_KEY=$SECRET_KEY" >> ~/.bashrc;
      echo $SECRET_KEY;
    else
      echo $SECRET_KEY;
    fi  
    if [ ! "$BOOTSTRAP_TOKEN" ]; then
      BOOTSTRAP_TOKEN=`cat /dev/urandom | tr -dc A-Za-z0-9 | head -c 16`;
      echo "BOOTSTRAP_TOKEN=$BOOTSTRAP_TOKEN" >> ~/.bashrc;
      echo $BOOTSTRAP_TOKEN;
    else
      echo $BOOTSTRAP_TOKEN;
    fi
    [root@yinzhengjie.com ~]# 
    [root@yinzhengjie.com ~]# bash random_encryption.sh          #生成的密钥下一步会用到,执行一次即可,以后需要重复使用哟!
    dPl4pOanKynSt8Sjcr4GEJWW2bn0tbLU7ToSMF5b4nvmsLlppF
    cJUGaQa9Xu4dT4EV
    [root@yinzhengjie.com ~]# 
    复制代码

    5>.启动Docker镜像

    复制代码
    [root@yinzhengjie.com ~]# docker image ls
    REPOSITORY           TAG                 IMAGE ID            CREATED             SIZE
    jumpserver/jms_all   latest              aebdcad38356        11 days ago         1.48GB
    [root@yinzhengjie.com ~]# 
    [root@yinzhengjie.com ~]# docker container ls
    CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
    [root@yinzhengjie.com ~]# 
    [root@yinzhengjie.com ~]# mkdir /opt/jumpserver
    [root@yinzhengjie.com ~]# 
    [root@yinzhengjie.com ~]# docker run --name yinzhengjie-jumpserver -d 
    > -v /opt/jumpserver:/opt/jumpserver/data/media 
    > -p 80:80 
    > -p 2222:2222 
    > -e SECRET_KEY=dPl4pOanKynSt8Sjcr4GEJWW2bn0tbLU7ToSMF5b4nvmsLlppF 
    > -e BOOTSTRAP_TOKEN=cJUGaQa9Xu4dT4EV 
    > -e DB_HOST=172.200.1.254 
    > -e DB_PORT=3306 
    > -e DB_USER=jumpserver 
    > -e DB_PASSWORD=yinzhengjie 
    > -e DB_NAME=jumpserver 
    > -e REDIS_HOST=172.200.1.254 
    > -e REDIS_PORT=6379 
    > -e REDIS_PASSWORD=yinzhengjie 
    > jumpserver/jms_all:latest
    df53e78889e7ef7b081fc2fe7bc6088850441b160ec3e5bf61b447d99d5742fe
    [root@yinzhengjie.com ~]# 
    [root@yinzhengjie.com ~]# docker container ls
    CONTAINER ID        IMAGE                       COMMAND             CREATED             STATUS              PORTS                                        NAMES
    df53e78889e7        jumpserver/jms_all:latest   "./entrypoint.sh"   7 seconds ago       Up 5 seconds        0.0.0.0:80->80/tcp, 0.0.0.0:2222->2222/tcp   yinzhengjie-jumpserver
    [root@yinzhengjie.com
    ~]#
    复制代码
     [root@yinzhengjie.com ~]# docker logs -f df53e78889e7                #查看容器的日志信息

    6>.访问JumpServer的WebUI

    复制代码
    [root@yinzhengjie.com ~]# ss -ntl
    State      Recv-Q Send-Q                                         Local Address:Port   
    LISTEN     0      50                                                         *:3306   
    LISTEN     0      511                                            172.200.1.254:6379   
    LISTEN     0      128                                                        *:22     
    LISTEN     0      20480                                                     :::2222   
    LISTEN     0      20480                                                     :::80     
    LISTEN     0      128                                                       :::22     
    [root@yinzhengjie.com ~]# 
    [root@yinzhengjie.com ~]# hostname -i
    172.200.1.254
    [root@yinzhengjie.com ~]# 
    复制代码

    7>.JumpServer部署成功

    8>.博主推荐阅读

    复制代码
      JumpServer的用户管理:
        https://www.cnblogs.com/yinzhengjie/p/12380734.html
    
      JumpServer的资产管理:
        https://www.cnblogs.com/yinzhengjie/p/12386493.html
    
        JumpServer的权限管理:
            https://www.cnblogs.com/yinzhengjie/p/12764722.html
            
        JumpServer的会话管理及命令过滤器应用案例:
            https://www.cnblogs.com/yinzhengjie/p/12811794.html
    复制代码

     

    当你的才华还撑不起你的野心的时候,你就应该静下心来学习。当你的能力还驾驭不了你的目标的时候,你就应该沉下心来历练。问问自己,想要怎样的人生。
    为人:谦逊、激情、博学、审问、慎思、明辨、 笃行
    学问:纸上得来终觉浅,绝知此事要躬行
    为事:工欲善其事,必先利其器。
    态度:道阻且长,行则将至;行而不辍,未来可期
    转载请标注出处!
  • 相关阅读:
    Java并发编程:线程池的使用
    多线程笔记
    《Java源码解析》之NIO的Selector机制(Part1:Selector.open())
    git reset --hard 和 git reset --sort区别
    java 泛型
    01springboot简介
    Selector 实现原理
    -Dmaven.multiModuleProjectDirectory system property is not set. Check $M2_HOME environment variable
    activemq使用
    8年javascript总结
  • 原文地址:https://www.cnblogs.com/ios9/p/14637535.html
Copyright © 2011-2022 走看看