开源堡垒机jumpserver的搭建与使用

 

目录

一. 准备 Python3 和 Python 虚拟环境

二. 安装 Jumpserver

三. 安装 SSH Server 和 WebSocket Server: Coco

四. 安装 Web Terminal 前端: Luna

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

六. 配置 Nginx 整合各组件

七. Jumpserver使用


跳板机jumpserver主要功能:

 

  • 用户/用户组:用户是授权和登录的主体,用户组方便组织授权
  • 会话记录/命令记录:实时监控在线用户操作,支持录像回放,可中断用户不良操作
  • 资产/资产树:采纳资产树组织资产,管理起来异常方便
  • 跨云部署:一个中心节点,各区域部署接入节点,统一管理
  • 授权规则:使用资产树授权,当节点资产变化时,自动继承授权.
  • web终端:领先的Web Terminal方案,支持Windows
  • 参考文档:https://docs.jumpserver.org/zh/master/setup_by_centos7.html

生产环境建议使用 1.4.8 版本

组件说明

  • Jumpserver 为管理后台, 管理员可以通过 Web 页面进行资产管理、用户管理、资产授权等操作, 用户可以通过 Web 页面进行资产登录, 文件管理等操作
  • koko 为 SSH Server 和 Web Terminal Server 。用户可以使用自己的账户通过 SSH 或者 Web Terminal 访问 SSH 协议和 Telnet 协议资产
  • Luna 为 Web Terminal Server 前端页面, 用户使用 Web Terminal 方式登录所需要的组件
  • Guacamole 为 RDP 协议和 VNC 协议资产组件, 用户可以通过 Web Terminal 来连接 RDP 协议和 VNC 协议资产 (暂时只能通过 Web Terminal 来访问)

端口说明

  • Jumpserver 默认端口为 8080/tcp 配置文件 jumpserver/config.yml
  • koko 默认 SSH 端口为 2222/tcp, 默认 Web Terminal 端口为 5000/tcp 配置文件在 koko/config.yml
  • Guacamole 默认端口为 8081/tcp, 配置文件 /config/tomcat9/conf/server.xml
  • Nginx 默认端口为 80/tcp
  • Redis 默认端口为 6379/tcp
  • Mysql 默认端口为 3306/tcp

Protocol

Server name

Port

TCP

Jumpserver

8080

TCP

koko

2222, 5000

TCP

Guacamole

8081

TCP

Db

3306

TCP

Redis

6379

TCP

Nginx

80

 

部署环境:

  • 系统: CentOS 7
  • IP: 192.168.92.134
  • 设置防火墙和selinux关闭:
    systemctl disable firewalld
    setenforce 0
    sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/sysconfig/selinux
  • 修改主机名:
    hostnamectl --static set-hostname MyVM02   [这条命令在centos7中是永久有效的]

部署步骤:

一. 准备 Python3 和 Python 虚拟环境

  1. 安装依赖包
    yum -y install wget sqlite-devel xz gcc automake zlib-devel openssl-devel epel-release git
  2. 安装 Python3.6  (https://www.python.org/ftp/python/3.6.1/)  也可以这里下载oa0x 
    将下载好的安装包上传到 /opt 目录下
     
    tar -xf Python-3.6.1.tar.xz
    cd Python-3.6.1/
    ./configure && make -j4 && make install
    #出现这代表成功
    
    	esac; \
    	 ./python -E -m ensurepip \
    		$ensurepip --root=/ ; \
    fi
    Collecting setuptools
    Collecting pip
    Installing collected packages: setuptools, pip
    Successfully installed pip-9.0.1 setuptools-28.8.0
    

     

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

二. 安装 Jumpserver

  1. 下载或 Clone 项目
    项目提交较多 git clone 时较大, 你可以选择去 Github 项目页面直接下载zip包
    (py3) [root@MyVM02 opt]# git clone --depth=1 https://github.com/jumpserver/jumpserver.git
    
    正克隆到 'jumpserver'...
    remote: Enumerating objects: 1156, done.
    remote: Counting objects: 100% (1156/1156), done.
    remote: Compressing objects: 100% (1028/1028), done.
    remote: Total 1156 (delta 193), reused 633 (delta 64), pack-reused 0
    接收对象中: 100% (1156/1156), 6.96 MiB | 57.00 KiB/s, done.
    处理 delta 中: 100% (193/193), done.
    
    

     

  2. 安装依赖 RPM 包

    (py3) [root@MyVM02 opt]# cd jumpserver/requirements/
    (py3) [root@MyVM02 requirements]# ls
    alpine_requirements.txt  deb_requirements.txt  issues.txt  mac_requirements.txt  requirements.txt  rpm_requirements.txt
    (py3) [root@MyVM02 requirements]# cat rpm_requirements.txt 
    libtiff-devel libjpeg-devel libzip-devel freetype-devel lcms2-devel libwebp-devel tcl-devel tk-devel sshpass openldap-devel mariadb-devel mysql-devel libffi-devel openssh-clients telnet openldap-clients 
    (py3) [root@MyVM02 requirements]# yum -y install $(cat rpm_requirements.txt)
    
    #如果编译报错,比如
    #Error downloading packages:   1:tk-8.5.13-6.el7.x86_64: [Errno 256] No more mirrors to try.
    
    1:执行yum clean all 清除缓存目录下的软件包及旧的headers;
    
    2:接着执行 yum list 重新列出所有已经安装和可以安装的软件包;
    
    3:重新执行上述命令,发现yum编译成功;
    
    注意:如果执行 yum list 报错,那就检查一下yum仓库是否有问题;并清除/etc/yum.repos.d/下多余.repo文件!

     

  3. 安装 Python 库依赖

    #使用国内阿里源
    (py3) [root@MyVM02 requirements]# pip install --upgrade pip setuptools -i https://mirrors.aliyun.com/pypi/simple/
    Collecting pip
      Downloading https://mirrors.aliyun.com/pypi/packages/30/db/9e38760b32e3e7f40cce46dd5fb107b8c73840df38f0046d8e6514e675a1/pip-19.2.3-py2.py3-none-any.whl (1.4MB)
        100% |████████████████████████████████| 1.4MB 507kB/s 
    Collecting setuptools
      Downloading https://mirrors.aliyun.com/pypi/packages/b2/86/095d2f7829badc207c893dd4ac767e871f6cd547145df797ea26baea4e2e/setuptools-41.2.0-py2.py3-none-any.whl (576kB)
        100% |████████████████████████████████| 583kB 1.0MB/s 
    Installing collected packages: pip, setuptools
      Found existing installation: pip 8.1.2
        Uninstalling pip-8.1.2:
          Successfully uninstalled pip-8.1.2
      Found existing installation: setuptools 0.9.8
        Uninstalling setuptools-0.9.8:
          Successfully uninstalled setuptools-0.9.8
    Successfully installed pip-19.2.3 setuptools-41.2.0
    
    (py3) [root@MyVM02 requirements]#pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/
    
    ''''
    ''''
    ''''
      Running setup.py install for django-redis-sessions ... done
      Running setup.py install for unicodecsv ... done
    Successfully installed Django-2.1.7 ForgeryPy-0.1 Jinja2-2.10.1 MarkupSafe-1.0 Pillow-4.3.0 PyNaCl-1.2.1 PyYAML-5.1 Werkzeug-0.14.1 aliyun-python-sdk-core-v3-2.9.1 aliyun-python-sdk-ecs-4.10.1 amqp-2.1.4 ansible-2.8.0 asn1crypto-0.24.0 azure-common-1.1.23 azure-nspkg-3.0.2 azure-storage-blob-1.3.1 azure-storage-common-1.4.2 azure-storage-nspkg-3.1.0 bcrypt-3.1.4 billiard-3.5.0.3 boto-2.49.0 boto3-1.6.5 botocore-1.9.5 celery-4.1.0 certifi-2018.1.18 cffi-1.11.5 chardet-3.0.4 configparser-3.5.0 coreapi-2.3.3 coreschema-0.0.4 crcmod-1.7 cryptography-2.3.1 decorator-4.1.2 django-auth-ldap-1.7.0 django-bootstrap3-9.1.0 django-celery-beat-1.4.0 django-filter-2.0.0 django-formtools-2.1 django-radius-1.3.3 django-ranged-response-0.2.0 django-redis-cache-1.7.1 django-redis-sessions-0.6.1 django-rest-swagger-2.1.2 django-simple-captcha-0.5.6 django-timezone-field-3.0 djangorestframework-3.9.4 djangorestframework-bulk-0.2.1 dnspython-1.16.0 docutils-0.14 drf-nested-routers-0.91 drf-yasg-1.9.1 ecdsa-0.13 elasticsearch-6.1.1 enum-compat-0.0.2 ephem-3.7.6.0 eventlet-0.24.1 future-0.17.1 greenlet-0.4.14 gunicorn-19.9.0 idna-2.6 inflection-0.3.1 ipip-ipdb-1.2.1 itsdangerous-0.24 itypes-1.1.0 jmespath-0.9.3 jms-storage-0.0.23 kombu-4.0.2 ldap3-2.4 monotonic-1.5 mysqlclient-1.3.14 netaddr-0.7.19 olefile-0.44 openapi-codec-1.3.2 oss2-2.4.0 paramiko-2.4.2 passlib-1.7.1 pyasn1-0.4.2 pyasn1-modules-0.2.6 pycparser-2.19 pycrypto-2.6.1 pycryptodome-3.9.0 pyotp-2.2.6 pyrad-2.1 python-crontab-2.3.8 python-dateutil-2.6.1 python-gssapi-0.6.4 python-jose-3.0.1 python-keycloak-0.13.3 python-keycloak-client-0.1.3 python-ldap-3.1.0 pytz-2018.3 redis-2.10.6 requests-2.22.0 rest-condition-1.0.3 rsa-4.0 ruamel.yaml-0.16.5 ruamel.yaml.clib-0.1.2 s3transfer-0.1.13 simplejson-3.13.2 six-1.11.0 sshpubkeys-3.1.0 tencentcloud-sdk-python-3.0.40 unicodecsv-0.14.1 uritemplate-3.0.0 urllib3-1.25.2 vine-1.1.4
    You are using pip version 9.0.1, however version 19.2.3 is available.
    You should consider upgrading via the 'pip install --upgrade pip' command.
    (py3) [root@MyVM02 requirements]#

     

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

    yum install redis -y
    systemctl start redis
    systemctl enable redis

     

  5. 安装 MySQL

    yum install mariadb mariadb-devel mariadb-server -y
    systemctl start mariadb
    systemctl enable mariadb

     

  6. 创建数据库 Jumpserver 并授权
    $ mysql -uroot
    > create database jumpserver default charset 'utf8';
    > grant all on jumpserver.* to 'jumpserver'@'127.0.0.1' identified by 'jumpserver';
    > flush privileges;
    > quit
  7. 修改 Jumpserver 配置文件

    cd ..
    
    #复制yml模板文件
    cp config_example.yml config.yml
    #取随机数,并写入到root下面的.bashrc里面中
    SECRET_KEY=`cat /dev/urandom | tr -dc A-Za-z0-9 | head -c 50`
    echo "SECRET_KEY=$SECRET_KEY" >> ~/.bashrc
    BOOTSTRAP_TOKEN=`cat /dev/urandom | tr -dc A-Za-z0-9 | head -c 16`
    echo "BOOTSTRAP_TOKEN=$BOOTSTRAP_TOKEN" >> ~/.bashrc
    
    #对config.yml文件进行修改配置
    sed -i "s/SECRET_KEY:/SECRET_KEY: $SECRET_KEY/g" /opt/jumpserver/config.yml
    
    sed -i "s/BOOTSTRAP_TOKEN:/BOOTSTRAP_TOKEN: $BOOTSTRAP_TOKEN/g" /opt/jumpserver/config.yml
    
    sed -i "s/# DEBUG: true/DEBUG: false/g" /opt/jumpserver/config.yml
    
    sed -i "s/# LOG_LEVEL: DEBUG/LOG_LEVEL: ERROR/g" /opt/jumpserver/config.yml
    
    sed -i "s/# SESSION_EXPIRE_AT_BROWSER_CLOSE: false/SESSION_EXPIRE_AT_BROWSER_CLOSE: true/g" /opt/jumpserver/config.yml
    
    sed -i "s/DB_PASSWORD:/DB_PASSWORD: jumpserver/g" /opt/jumpserver/config.yml 
    
    ###配置详解:
    # SECURITY WARNING: keep the secret key used in production secret!
    # 加密秘钥 生产环境中请修改为随机字符串, 请勿外泄, PS: 纯数字不可以
    SECRET_KEY:
    
    # SECURITY WARNING: keep the bootstrap token used in production secret!
    # 预共享Token koko和guacamole用来注册服务账号, 不在使用原来的注册接受机制
    BOOTSTRAP_TOKEN:
    
    # Development env open this, when error occur display the full process track, Production disable it
    # DEBUG 模式 开启DEBUG后遇到错误时可以看到更多日志
    DEBUG: false
    
    # DEBUG, INFO, WARNING, ERROR, CRITICAL can set. See https://docs.djangoproject.com/en/1.10/topics/logging/
    # 日志级别
    LOG_LEVEL: ERROR
    # LOG_DIR:
    # Session expiration setting, Default 24 hour, Also set expired on on browser close
    # 浏览器Session过期时间, 默认24小时, 也可以设置浏览器关闭则过期
    # SESSION_COOKIE_AGE: 86400
    SESSION_EXPIRE_AT_BROWSER_CLOSE: true
    
    # Database setting, Support sqlite3, mysql, postgres ....
    # 数据库设置
    # See https://docs.djangoproject.com/en/1.10/ref/settings/#databases
    
    # SQLite setting:
    # 使用单文件sqlite数据库
    # DB_ENGINE: sqlite3
    # DB_NAME:
    
    # MySQL or postgres setting like:
    # 使用Mysql作为数据库
    DB_ENGINE: mysql
    DB_HOST: 127.0.0.1
    DB_PORT: 3306
    DB_USER: jumpserver
    DB_PASSWORD: jumpserver
    DB_NAME: jumpserver
    
    # When Django start it will bind this host and port
    # ./manage.py runserver 127.0.0.1:8080
    # 运行时绑定端口
    HTTP_BIND_HOST: 0.0.0.0
    HTTP_LISTEN_PORT: 8080
    
    # Use Redis as broker for celery and web socket
    # Redis配置
    REDIS_HOST: 127.0.0.1
    REDIS_PORT: 6379
    # REDIS_PASSWORD:
    # REDIS_DB_CELERY: 3
    # REDIS_DB_CACHE: 4
    
    # Use OpenID authorization
    # 使用OpenID 来进行认证设置
    # BASE_SITE_URL: http://localhost:8080
    # AUTH_OPENID: false  # True or False
    # AUTH_OPENID_SERVER_URL: https://openid-auth-server.com/
    # AUTH_OPENID_REALM_NAME: realm-name
    # AUTH_OPENID_CLIENT_ID: client-id
    # AUTH_OPENID_CLIENT_SECRET: client-secret
    
    # OTP settings
    # OTP/MFA 配置
    # OTP_VALID_WINDOW: 0
    # OTP_ISSUER_NAME: Jumpserver

     

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

    (py3) [root@MyVM02 jumpserver]# ./jms start all -d
    
    ...
    ...
    ...
      Applying users.0021_auto_20190625_1104... OK
      Applying users.0022_auto_20190625_1105... OK
    Collect static files
    Collect static file done
    
    - Start Celery as Distributed Task Queue
    
    - Start Beat as Periodic Task Scheduler
    Error: celery start error
    Stop service: gunicorn
    celery is stopped
    beat is stopped
    (py3) [root@MyVM02 jumpserver]# 
    

    这里只是 Jumpserver, 没有 Web Terminal,所以访问 Web Terminal 会报错
    浏览器访问 http://192.168.92.134:8080/
    账号admin , 密码admin
    页面显示不正常先不用处理,继续往下操作,后面搭建 nginx 代理后即可正常访问,原因是因为 django 无法在非 debug 模式下加载静态资源

三. 安装 SSH Server 和 WebSocket Server: Coco

  1. 下载或 Clone 项目

    (py3) [root@MyVM02 jumpserver]# cd /opt
    (py3) [root@MyVM02 jumpserver]# git clone --depth=1 https://github.com/jumpserver/coco.git
    (py3) [root@MyVM02 jumpserver]# echo "source /opt/py3/bin/activate" > /opt/coco/.env  # 进入 coco 目录时将自动载入 python 虚拟环境

     

  2. 安装依赖
    (py3) [root@MyVM02 opt]# cd /opt/coco/requirements
    (py3) [root@MyVM02 opt]# yum -y  install $(cat rpm_requirements.txt)
    #默认的pip源的速度实在无法忍受,推荐国内阿里源下载
    (py3) [root@MyVM02 opt]# pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/
    

  3. 修改配置文件并运行
     

    cd /opt/coco
    
    (py3) [root@MyVM02 coco]# cp config_example.yml config.yml
    
    [root@MyVM02 coco]# sed -i "s/BOOTSTRAP_TOKEN: <PleasgeChangeSameWithJumpserver>/BOOTSTRAP_TOKEN: $BOOTSTRAP_TOKEN/g" /opt/coco/config.yml
    [root@MyVM02 coco]# sed -i "s/# LOG_LEVEL: INFO/LOG_LEVEL: ERROR/g" /opt/coco/config.yml
    
    
    (py3) [root@MyVM02 coco]# cat config.yml 
    # 项目名称, 会用来向Jumpserver注册, 识别而已, 不能重复
    # NAME: {{ Hostname }}
    
    # Jumpserver项目的url, api请求注册会使用
    CORE_HOST: http://127.0.0.1:8080
    
    # Bootstrap Token, 预共享秘钥, 用来注册coco使用的service account和terminal
    # 请和jumpserver 配置文件中保持一致,注册完成后可以删除
    BOOTSTRAP_TOKEN: XG2NPXcRRNuFWxfz
    
    # 启动时绑定的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: null
    
    # ACCESS KEY 保存的地址, 默认注册后会保存到该文件中
    # ACCESS_KEY_FILE: data/keys/.access_key
    
    # 加密密钥
    # SECRET_KEY: null
    
    # 设置日志级别 [DEBUG, INFO, WARN, ERROR, FATAL, CRITICAL]
    LOG_LEVEL: ERROR
    
    # 日志存放的目录
    # LOG_DIR: logs
    
    # SSH白名单
    # ALLOW_SSH_USER: all
    
    # SSH黑名单, 如果用户同时在白名单和黑名单,黑名单优先生效
    # BLOCK_SSH_USER:
    #   -
    
    # 和Jumpserver 保持心跳时间间隔
    # HEARTBEAT_INTERVAL: 5
    
    # Admin的名字,出问题会提示给用户
    # ADMINS: ''
    
    # SSH连接超时时间 (default 15 seconds)
    # SSH_TIMEOUT: 15
    
    # 语言 [en,zh]
    # LANGUAGE_CODE: zh
    
    # SFTP的根目录, 可选 /tmp, Home其他自定义目录
    # SFTP_ROOT: /tmp
    
    # SFTP是否显示隐藏文件
    # SFTP_SHOW_HIDDEN_FILE: false
    
    # 是否复用和用户后端资产已建立的连接(用户不会复用其他用户的连接)
    # REUSE_CONNECTION: true
    
    # 是否强制删除文件夹:(default false)
    # FORCE_REMOVE_FOLDER: false
    
    # Telnet连接协商使用的终端类型
    # TELNET_TTYPE: XTERM-256COLOR
    (py3) [root@MyVM02 coco]# ./cocod start -d     # 后台运行使用 -d 参数./cocod start -d
    Use eventlet dispatch
    Start coco process
    (py3) [root@MyVM02 coco]# netstat -nltp | grep 2222
    tcp        0      0 0.0.0.0:2222            0.0.0.0:*               LISTEN      23435/python3    
    
    # 新版本更新了运行脚本, 使用方式./cocod start|stop|status  后台运行请添加 -d 
    
    #终端连接
    (py3) [root@MyVM02 coco]#  ssh -p2222 [email protected]
    输入admin密码 admin即可
    

四. 安装 Web Terminal 前端: Luna

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

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

  • 解压luna
    (py3) [root@MyVM02 coco]# cd /opt/
    (py3) [root@MyVM02 opt]# wget https://github.com/jumpserver/luna/releases/download/1.4.8/luna.tar.gz
    (py3) [root@MyVM02 opt]# tar xf luna.tar.gz
    (py3) [root@MyVM02 opt]# chown -R root:root luna
    ————————————————
    

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

  1. 安装依赖
    (py3) [root@MyVM02 opt]# mkdir /usr/local/lib/freerdp/
    (py3) [root@MyVM02 opt]# ln -s /usr/local/lib/freerdp /usr/lib64/freerdp
    (py3) [root@MyVM02 opt]# rpm --import http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro
    (py3) [root@MyVM02 opt]# rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm
    (py3) [root@MyVM02 opt]# yum -y localinstall --nogpgcheck https://download1.rpmfusion.org/free/el/rpmfusion-free-release-7.noarch.rpm https://download1.rpmfusion.org/nonfree/el/rpmfusion-nonfree-release-7.noarch.rpm
     
    (py3) [root@MyVM02 opt]# yum install -y java-1.8.0-openjdk libtool
    (py3) [root@MyVM02 opt]# yum install -y cairo-devel libjpeg-turbo-devel libpng-devel uuid-devel
    (py3) [root@MyVM02 opt]# yum install -y ffmpeg-devel freerdp-devel freerdp-plugins pango-devel libssh2-devel libtelnet-devel libvncserver-devel pulseaudio-libs-devel openssl-devel libvorbis-devel libwebp-devel ghostscript
    
  2. 编译安装 guacamole 服务

    (py3) [root@MyVM02 opt]# cd /opt
    (py3) [root@MyVM02 opt]# git clone https://github.com/jumpserver/docker-guacamole.git
    (py3) [root@MyVM02 opt]# cd /opt/docker-guacamole/
    (py3) [root@MyVM02 docker-guacamole ]# tar -xf guacamole-server-0.9.14.tar.gz
    (py3) [root@MyVM02 docker-guacamole ]# cd guacamole-server-0.9.14
    (py3) [root@MyVM02 guacamole-server-0.9.14 ]# autoreconf -fi
    (py3) [root@MyVM02 guacamole-server-0.9.14 ]# ./configure --with-init-dir=/etc/init.d
    (py3) [root@MyVM02 guacamole-server-0.9.14 ]# make && make install
    (py3) [root@MyVM02 guacamole-server-0.9.14 ]# cd ..
    (py3) [root@MyVM02 docker-guacamole ]# rm -rf guacamole-server-0.9.14
    (py3) [root@MyVM02 docker-guacamole ]# ldconfig
    

     

  3. 配置 Tomcat

    (py3) [root@MyVM02 coco]# mkdir -p /config/guacamole /config/guacamole/lib /config/guacamole/extensions # 创建 guacamole 目录
    (py3) [root@MyVM02 coco]# ln -sf /opt/docker-guacamole/guacamole-auth-jumpserver-1.0.0.jar /config/guacamole/extensions/guacamole-auth-jumpserver-1.0.0.jar
    (py3) [root@MyVM02 coco]# ln -sf /opt/docker-guacamole/root/app/guacamole/guacamole.properties /config/guacamole/guacamole.properties # guacamole 配置文件
    
     
    (py3) [root@MyVM02 docker-guacamole ]# cd /config
    (py3) [root@MyVM02 config ]# wget http://mirror.bit.edu.cn/apache/tomcat/tomcat-8/v8.5.45/bin/apache-tomcat-8.5.45.tar.gz
    (py3) [root@MyVM02 config ]# tar xf apache-tomcat-8.5.38.tar.gz
    (py3) [root@MyVM02 config ]# rm -rf apache-tomcat-8.5.38.tar.gz
    (py3) [root@MyVM02 config ]# mv apache-tomcat-8.5.38 tomcat8
    (py3) [root@MyVM02 config ]# rm -rf /config/tomcat8/webapps/*
    (py3) [root@MyVM02 config ]# ln -sf /opt/docker-guacamole/guacamole-1.0.0.war /config/tomcat8/webapps/ROOT.war # guacamole client
    (py3) [root@MyVM02 config ]# sed -i 's/Connector port="8080"/Connector port="8081"/g' /config/tomcat8/conf/server.xml # 修改默认端口为 8081
    (py3) [root@MyVM02 config ]# sed -i 's/FINE/WARNING/g' /config/tomcat8/conf/logging.properties # 修改 log 等级为 WARNING
     
    (py3) [root@MyVM02 config ]# wget https://github.com/ibuler/ssh-forward/releases/download/v0.0.5/linux-amd64.tar.gz
    (py3) [root@MyVM02 config ]# tar xf linux-amd64.tar.gz -C /bin/
    (py3) [root@MyVM02 config ]# chmod +x /bin/ssh-forward

     

  4. 配置环境变量

    (py3) [root@MyVM02 config ]# export JUMPSERVER_SERVER=http://127.0.0.1:8080 # http://127.0.0.1:8080 指 jumpserver 访问地址
    $ echo "export JUMPSERVER_SERVER=http://127.0.0.1:8080" >> ~/.bashrc
    # BOOTSTRAP_TOKEN 为 Jumpserver/config.yml 里面的 BOOTSTRAP_TOKEN
    (py3) [root@MyVM02 config ]# export BOOTSTRAP_TOKEN=$BOOTSTRAP_TOKEN
    (py3) [root@MyVM02 config ]# echo "export BOOTSTRAP_TOKEN=$BOOTSTRAP_TOKEN" >> ~/.bashrc
    (py3) [root@MyVM02 config ]# export JUMPSERVER_KEY_DIR=/config/guacamole/keys
    (py3) [root@MyVM02 config ]# echo "export JUMPSERVER_KEY_DIR=/config/guacamole/keys" >> ~/.bashrc
    (py3) [root@MyVM02 config ]# export GUACAMOLE_HOME=/config/guacamole
    (py3) [root@MyVM02 config ]# echo "export GUACAMOLE_HOME=/config/guacamole" >> ~/.bashrc

     

  5. 启动 Guacamole
    (py3) [root@MyVM02 config]# /etc/init.d/guacd start
    Starting guacd: guacd[3699]: INFO:	Guacamole proxy daemon (guacd) version 1.0.0 started
    SUCCESS
    (py3) [root@MyVM02 config]# sh /config/tomcat8/bin/startup.sh 
    Using CATALINA_BASE:   /config/tomcat8
    Using CATALINA_HOME:   /config/tomcat8
    Using CATALINA_TMPDIR: /config/tomcat8/temp
    Using JRE_HOME:        /usr
    Using CLASSPATH:       /config/tomcat8/bin/bootstrap.jar:/config/tomcat8/bin/tomcat-juli.jar
    Tomcat started.
    

     

六. 配置 Nginx 整合各组件

  1. 安装 Nginx (下面提供yum安装,源码安装请点击)
     

    (py3) [root@MyVM02 opt]# vim /etc/yum.repos.d/nginx.repo
    
    [nginx-stable]
    name=nginx stable repo
    baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
    gpgcheck=1
    enabled=1
    gpgkey=https://nginx.org/keys/nginx_signing.key
    
    (py3) [root@MyVM02 opt]# yum makecache fast
    (py3) [root@MyVM02 opt]# yum -y install nginx
    (py3) [root@MyVM02 config]# rm -rf /etc/nginx/conf.d/default.conf 
    (py3) [root@MyVM02 config]# systemctl enable nginx
    Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.
    

     

  2. 准备配置文件 (也可以点击下载配置文件 a8te)

    (py3) [root@MyVM02 opt]# vim /etc/nginx/conf.d/jumpserver.conf
    
    server {
        listen 80;  # 代理端口, 以后将通过此端口进行访问, 不再通过8080端口
        # server_name demo.jumpserver.org;  # 修改成你的域名或者注释掉
        client_max_body_size 100m;  # 录像及文件上传大小限制
        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 /coco/ {
            proxy_pass       http://localhost:5000/coco/;  # 如果coco安装在别的服务器, 请填写它的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;
            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;
        }
    }

     

  3. 运行 Nginx

    (py3) [root@MyVM02 conf.d]# nginx -t # 确保配置没有问题, 有问题请先解决
    nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
    nginx: configuration file /etc/nginx/nginx.conf test is successful
    (py3) [root@MyVM02 conf.d]# systemctl start nginx
    (py3) [root@MyVM02 conf.d]# systemctl enable nginx
    (py3) [root@MyVM02 conf.d]# lsof -i:80
    COMMAND  PID  USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
    nginx   4857  root    6u  IPv4  48806      0t0  TCP *:http (LISTEN)
    nginx   4858 nginx    6u  IPv4  48806      0t0  TCP *:http (LISTEN)
    

     

  4. 开始使用 Jumpserver
    检查应用是否已经正常运行
    服务全部启动后, 访问http://192.168.92.134, 访问nginx代理的端口, 不要再通过8080端口访问
    默认账号: admin 密码: admin
    到Jumpserver 会话管理-终端管理 检查 Coco Guacamole 等应用的注册。



    测试连接

    
    如果登录客户端是 macOS 或 Linux, 登录语法如下
    $ ssh -p2222 [email protected]
    $ sftp -P2222 [email protected]
    密码: admin
     
    如果登录客户端是 Windows, Xshell Terminal 登录语法如下
    $ ssh [email protected]
    $ sftp [email protected]
    密码: admin
    如果能登陆代表部署成功
     
    # sftp默认上传的位置在资产的 /tmp 目录下
    # windows拖拽上传的位置在资产的 Guacamole RDP上的 G 目录下
    
    (py3) [root@MyVM02 conf.d]# ssh -p2222 [email protected]
    [email protected]'s password: 
    
    		 Administrator, 欢迎使用Jumpserver开源跳板机系统 
    
    	1) 输入 ID 直接登录 或 输入部分 IP,主机名,备注 进行搜索登录(如果唯一).
    	2) 输入 / + IP, 主机名 or 备注 搜索. 如: /ip
    	3) 输入 p 显示您有权限的主机.
    	4) 输入 g 显示您有权限的节点.
    	5) 输入 g + 节点ID 显示节点下主机. 如: g1
    	6) 输入 s 中/英文切换.
    	7) 输入 h 帮助.
    	8) 输入 r 刷新最新的机器和节点信息.
    	0) 输入 q 退出.
    
    Opt> 
    
    


     

七. Jumpserver使用

  1. 创建 Jumpserver 用户
    用户管理>>用户列表>>创建用户

     

    (py3) [root@MyVM02 conf.d]# ssh -p2222 [email protected]
    [email protected]'s password: 
    
    		 songqingfeng, 欢迎使用Jumpserver开源跳板机系统 
    
    	1) 输入 ID 直接登录 或 输入部分 IP,主机名,备注 进行搜索登录(如果唯一).
    	2) 输入 / + IP, 主机名 or 备注 搜索. 如: /ip
    	3) 输入 p 显示您有权限的主机.
    	4) 输入 g 显示您有权限的节点.
    	5) 输入 g + 节点ID 显示节点下主机. 如: g1
    	6) 输入 s 中/英文切换.
    	7) 输入 h 帮助.
    	8) 输入 r 刷新最新的机器和节点信息.
    	0) 输入 q 退出.
    
    Opt> 
    

     

  2. 创建管理用户
    资产管理>>管理用户>>创建管理用户(用户是资产服务器上存在的系统用户)

     
  3. 创建系统用户
    资产管理>>系统用户>>创建系统用户(资产服务器上存在的系统用户)

    密码要添加正确,终端能登陆即可
  4. 创建资产
    资产管理>>ROOT(右击可先新建节点)>>创建资产

  5. 资产授权
    权限管理>>资产授权>>创建授权规则

  6. 用户使用资产
    方法一:会话管理>>Web终端>>


    方法二:命令登陆
    是Mac或Linux,登录语法:ssh -p2222 [email protected]

    (py3) [root@MyVM02 conf.d]# ssh -p2222 [email protected]
    [email protected]'s password: 
    
    		 Administrator, 欢迎使用Jumpserver开源跳板机系统 
    
    	1) 输入 ID 直接登录 或 输入部分 IP,主机名,备注 进行搜索登录(如果唯一).
    	2) 输入 / + IP, 主机名 or 备注 搜索. 如: /ip
    	3) 输入 p 显示您有权限的主机.
    	4) 输入 g 显示您有权限的节点.
    	5) 输入 g + 节点ID 显示节点下主机. 如: g1
    	6) 输入 s 中/英文切换.
    	7) 输入 h 帮助.
    	8) 输入 r 刷新最新的机器和节点信息.
    	0) 输入 q 退出.
    
    Opt> p
    ID   主机名          IP               登录用户      备注                                                                                                                
    1    192.168.92.135  192.168.92.135   [root]                                                                                                                            
    2    192.168.92.137  192.168.92.137   [admin, root]                                                                                                                     
    
    页码: 1, 数量: 2, 总页数: 1, 总数量: 2
    
    Opt> 2
    
    选择一个登录:
    0 admin
    1 root
    ID> 1
    
    Last login: Tue Sep 24 14:59:11 2019 from 192.168.92.136
    [root@localhost ~]# ip a | grep ens
    2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
        inet 192.168.92.137/24 brd 192.168.92.255 scope global noprefixroute dynamic ens33
    [root@localhost ~]# ping www.baidu.com
    PING www.a.shifen.com (182.61.200.7) 56(84) bytes of data.
    64 bytes from 182.61.200.7 (182.61.200.7): icmp_seq=1 ttl=128 time=32.8 ms
    64 bytes from 182.61.200.7 (182.61.200.7): icmp_seq=2 ttl=128 time=32.9 ms
    ^C
    
    

     

  7. 设置邮件服务
    (py3) [root@web1 opt]# yum install -y mailx  ##安装邮件服务
    (py3) [root@web1 opt]# vim /etc/mail.rc  ##在配置文件最后添加
    
    set from=19***[email protected]  #(需修改)收件人显示的发件人名称,可填写你的名字等
    set smtp=smtp.qq.com  #(需修改)你所使用的外部邮箱的smtp服务器地址,这里使用qq的邮件
    set smtp-auth-user=19***[email protected]  #你所使用的外部邮箱的用户名
    set smtp-auth-password=xqfffcpwsmpxbgee  # QQ邮箱授权码,需要开启pop3和smtp就会生成
    set smtp-auth=login
    
    测试邮件发送
    (py3) [root@MyVM02 opt]# echo '我爱中国' |mailx -v -s "你好时光" [email protected]
    Resolving host smtp.qq.com . . . done.
    Connecting to 14.18.245.164:smtp . . . connected.
    220 smtp.qq.com Esmtp QQ Mail Server
    >>> EHLO MyVM02
    250-smtp.qq.com
    250-PIPELINING
    250-SIZE 73400320
    250-STARTTLS
    250-AUTH LOGIN PLAIN
    250-AUTH=LOGIN
    250-MAILCOMPRESS
    250 8BITMIME
    >>> AUTH LOGIN
    334 VXNlcm5hbWU6
    >>> MTkxMTg1MjY2QHFxLmNvbQ==
    334 UGFzc3dvcmQ6
    >>> eHFmZmZjcHdzbXB4YmdlZQ==
    235 Authentication successful
    >>> MAIL FROM:<[email protected]>
    250 Ok
    >>> RCPT TO:<[email protected]>
    250 Ok
    >>> DATA
    354 End data with <CR><LF>.<CR><LF>
    >>> .
    250 Ok: queued as 
    >>> QUIT
    221 Bye
    
    邮箱收件情况


    设置jumpserver邮件发送
    系统设置-->邮件设置


    创建个用户,填写邮箱


    收到注册成功邮件

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章