当前位置:   article > 正文

基于docker-compose部署jumpserver_docker的jumpserver/koko容器中config.yml中sshd_port参数需要打

docker的jumpserver/koko容器中config.yml中sshd_port参数需要打开么

基于docker-compose部署jumpserver

组件说明

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 默认 Web 端口为 8080/tcp, 默认 WS 端口为 8070/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

ProtocolServer namePort
TCPJumpserver80
TCPGuacamole 
TCPDb3306
TCPRedis6379
TCPkoko2222

环境

系统: Centos 7

NFS-server: 192.168.150.192

数据库 IP: 192.168.150.45

Redis ip: 192.168.150.45

Jumpserver IP: 192.168.150.45 192.168.150.26

koko IP: 192.168.150.45 192.168.150.26

Guacamole IP: 192.168.150.45 192.168.150.26

Tengine 代理IP: 192.168.150.45 192.168.150.26

安全设置

ssh、telnet协议 资产的防火墙设置允许 koko 与 jumpserver 访问

rdp协议 资产的防火墙设置允许 guacamole 与jumpserver 访问

防火墙设置

根据需求开放对应的端口,或者直接关闭防火墙

  1. systemctl stop firewalld.service
  2. systemctl disable firewalld.service

NFS部署

  1. 安装epel库

    yum -y install epel-release wget
  2. 安装nfs-server

    1. yum -y install nfs-utils rpcbind
    2. systemctl enable rpcbind nfs-server nfs-lock nfs-idmap
    3. systemctl start rpcbind nfs-server nfs-lock nfs-idmap
  3. 创建NFS共享目录

    mkdir /data
  4. 设置NFS访问权限

    1. vim /etc/exports
    2. /data 192.168.150.*(rw,sync,no_root_squash)

    /data 是刚才创建的将被共享的目录, 192.168.150. 表示整个 192.168.150. 的资产都有括号里面的权限
    也可以写具体的授权对象 /data 192.168.150.45(rw,sync,no_root_squash) 192.168.150.26(rw,sync,no_root_squash)

  5. 使exports生效

    exportfs -a
  6. 安装nfs-client (150.45 and 150.26)

    1. showmount -e 192.168.150.192
    2. mkdir -p /opt/jumpserver/data
    3. restorecon -R /opt/jumpserver/data/
    4. mount -t nfs 192.168.150.192:/data /opt/jumpserver/data
    5. echo "192.168.150.192:/data /opt/jumpserver/data nfs defaults 0 0" >> /etc/fstab

docker-compose部署

  1. 安装docker

安装以下依赖包

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

添加docker的yum源

yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

更新yum源缓存, 安装docker-ce

  1. $ sudo yum makecache fast
  2. $ sudo yum install docker-ce

配置镜像加速器

  1. sudo mkdir -p /etc/docker
  2. sudo tee /etc/docker/daemon.json <<-'EOF'
  3. {
  4. "registry-mirrors": ["https://zggyaen3.mirror.aliyuncs.com"]
  5. }
  6. EOF
  7. sudo systemctl daemon-reload
  8. sudo systemctl restart docker

普通用户需要加入docker组

$ sudo usermod -a -G docker ${USER}

修改docker存储位置(可以不改)

  1. $ sudo systemctl stop docker
  2. $ sudo mv /var/lib/docker /home/lan/docker
  3. $ sudo ln -s /home/lan/docker /var/lib/docker
  4. $ sudo systemctl start docker
  5. $ sudo systemctl enable docker
  1. docker-compose安装
  1. $ sudo curl -L https://github.com/docker/compose/releases/download/1.23.2/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
  2. $ sudo chmod +x /usr/local/bin/docker-compose

如果下载很慢可手动下载,再上传至系统

下载路径: https://github.com/docker/compose/releases/ 可以选择对应的版本下载

部署jumpserver

  1. 下载jumpserver压缩包

    1. wget https://github.com/jumpserver/Dockerfile.git
    2. unzip Dockerfile-master.zip
  2. 使用shell脚本生成SECRET_KEY和BOOTSTRAP_TOKEN

    1. if [ ! "$SECRET_KEY" ]; then
    2. SECRET_KEY=`cat /dev/urandom | tr -dc A-Za-z0-9 | head -c 50`;
    3. echo "SECRET_KEY=$SECRET_KEY" >> ~/.bashrc;
    4. echo $SECRET_KEY;
    5. else
    6. echo $SECRET_KEY;
    7. fi
    8. if [ ! "$BOOTSTRAP_TOKEN" ]; then
    9. BOOTSTRAP_TOKEN=`cat /dev/urandom | tr -dc A-Za-z0-9 | head -c 16`;
    10. echo "BOOTSTRAP_TOKEN=$BOOTSTRAP_TOKEN" >> ~/.bashrc;
    11. echo $BOOTSTRAP_TOKEN;
    12. else
    13. echo $BOOTSTRAP_TOKEN;
    14. fi
  3. 修改.env文件,设置mysql,redis密码

    vim .env
    
    1. # 版本号可以自己根据项目的版本修改
    2. Version=1.5.9
    3. # MySQL
    4. DB_HOST=192.168.150.45
    5. DB_PORT=3306
    6. DB_USER=jumpserver
    7. DB_PASSWORD=password
    8. DB_NAME=jumpserver
    9. # Redis
    10. REDIS_HOST=192.168.150.45
    11. REDIS_PORT=6379
    12. REDIS_PASSWORD=password
    13. # Core
    14. SECRET_KEY=15hMccXFn40TCKJETDnjlUhkZEXIAcq3E3aQ6T6LDmfLUN0oAV
    15. BOOTSTRAP_TOKEN=HT8qH0wSuyQjcNyh
    16. ##
    17. # SECRET_KEY 保护签名数据的密匙, 首次安装请一定要修改并牢记, 后续升级和迁移不可更改, 否则将导致加密的数据不可解密。
    18. # BOOTSTRAP_TOKEN 为组件认证使用的密钥, 仅组件注册时用。组件指 koko、guacamole

    在150.45上修改docker-compose

    vim docker-compose.yml
    
    1. version: '3' # 由于测试环境资源有限,我的mysql跟redis也是部署在了150.45, 所以在150.26那台上面指定mysql跟redis的地址就可以,不需要在启动mysql和redis的容器
    2. services:
    3. mysql:
    4. image: jumpserver/jms_mysql:${Version}
    5. container_name: jms_mysql
    6. restart: always
    7. tty: true
    8. environment:
    9. DB_PORT: $DB_PORT
    10. DB_USER: $DB_USER
    11. DB_PASSWORD: $DB_PASSWORD
    12. DB_NAME: $DB_NAME
    13. ports:
    14. - 3306:3306
    15. volumes:
    16. - /opt/jumpserver/data/mysql-master:/var/lib/mysql
    17. - /opt/jumpserver/data/mysql-master.cnf:/etc/my.cnf
    18. networks:
    19. - jumpserver
    20. redis:
    21. image: jumpserver/jms_redis:${Version}
    22. container_name: jms_redis
    23. restart: always
    24. tty: true
    25. environment:
    26. REDIS_PORT: $REDIS_PORT
    27. REDIS_PASSWORD: $REDIS_PASSWORD
    28. ports:
    29. - 6379:6379
    30. volumes:
    31. - /opt/jumpserver/data/redis-data:/var/lib/redis/
    32. networks:
    33. - jumpserver
    34. core:
    35. image: jumpserver/jms_core:${Version}
    36. container_name: jms_core
    37. restart: always
    38. tty: true
    39. environment:
    40. SECRET_KEY: $SECRET_KEY
    41. BOOTSTRAP_TOKEN: $BOOTSTRAP_TOKEN
    42. DB_HOST: $DB_HOST
    43. DB_PORT: $DB_PORT
    44. DB_USER: $DB_USER
    45. DB_PASSWORD: $DB_PASSWORD
    46. DB_NAME: $DB_NAME
    47. REDIS_HOST: $REDIS_HOST
    48. REDIS_PORT: $REDIS_PORT
    49. REDIS_PASSWORD: $REDIS_PASSWORD
    50. depends_on:
    51. - mysql
    52. - redis
    53. volumes:
    54. - core-data:/opt/jumpserver/data
    55. networks:
    56. - jumpserver
    57. koko:
    58. image: jumpserver/jms_koko:${Version}
    59. container_name: jms_koko
    60. restart: always
    61. tty: true
    62. environment:
    63. CORE_HOST: http://core:8080
    64. BOOTSTRAP_TOKEN: $BOOTSTRAP_TOKEN
    65. depends_on:
    66. - core
    67. - mysql
    68. - redis
    69. volumes:
    70. - koko-keys:/opt/koko/data/keys
    71. ports:
    72. - 2222:2222
    73. networks:
    74. - jumpserver
    75. guacamole:
    76. image: jumpserver/jms_guacamole:${Version}
    77. container_name: jms_guacamole
    78. restart: always
    79. tty: true
    80. environment:
    81. JUMPSERVER_SERVER: http://core:8080
    82. BOOTSTRAP_TOKEN: $BOOTSTRAP_TOKEN
    83. JUMPSERVER_KEY_DIR: /config/guacamole/keys
    84. GUACAMOLE_HOME: /config/guacamole
    85. GUACAMOLE_LOG_LEVEL: ERROR
    86. JUMPSERVER_ENABLE_DRIVE: 'true'
    87. depends_on:
    88. - core
    89. - mysql
    90. - redis
    91. volumes:
    92. - guacamole-keys:/config/guacamole/keys
    93. networks:
    94. - jumpserver
    95. nginx:
    96. image: jumpserver/jms_nginx:${Version}
    97. container_name: jms_nginx
    98. restart: always
    99. tty: true
    100. depends_on:
    101. - core
    102. - koko
    103. - mysql
    104. - redis
    105. volumes:
    106. - core-data:/opt/jumpserver/data
    107. ports:
    108. - 80:80
    109. networks:
    110. - jumpserver
    111. volumes:
    112. mysql-data:
    113. redis-data:
    114. core-data:
    115. koko-keys:
    116. guacamole-keys:
    117. networks:
    118. jumpserver:

    在150.26上修改docker-compose文件

    1. version: '3'
    2. services:
    3. core:
    4. image: jumpserver/jms_core:${Version}
    5. container_name: jms_core
    6. restart: always
    7. tty: true
    8. environment:
    9. SECRET_KEY: $SECRET_KEY
    10. BOOTSTRAP_TOKEN: $BOOTSTRAP_TOKEN
    11. DB_HOST: $DB_HOST
    12. DB_PORT: $DB_PORT
    13. DB_USER: $DB_USER
    14. DB_PASSWORD: $DB_PASSWORD
    15. DB_NAME: $DB_NAME
    16. REDIS_HOST: $REDIS_HOST
    17. REDIS_PORT: $REDIS_PORT
    18. REDIS_PASSWORD: $REDIS_PASSWORD
    19. volumes:
    20. - /opt/jumpserver/data/core-data:/opt/jumpserver/data
    21. networks:
    22. - jumpserver
    23. koko:
    24. image: jumpserver/jms_koko:${Version}
    25. container_name: jms_koko
    26. restart: always
    27. tty: true
    28. environment:
    29. CORE_HOST: http://core:8080
    30. BOOTSTRAP_TOKEN: $BOOTSTRAP_TOKEN
    31. depends_on:
    32. - core
    33. volumes:
    34. - /opt/jumpserver/data/koko-keys:/opt/koko/data/keys
    35. ports:
    36. - 2222:2222
    37. networks:
    38. - jumpserver
    39. guacamole:
    40. image: jumpserver/jms_guacamole:${Version}
    41. container_name: jms_guacamole
    42. restart: always
    43. tty: true
    44. environment:
    45. JUMPSERVER_SERVER: http://core:8080
    46. BOOTSTRAP_TOKEN: $BOOTSTRAP_TOKEN
    47. JUMPSERVER_KEY_DIR: /config/guacamole/keys
    48. GUACAMOLE_HOME: /config/guacamole
    49. GUACAMOLE_LOG_LEVEL: ERROR
    50. JUMPSERVER_ENABLE_DRIVE: 'true'
    51. depends_on:
    52. - core
    53. volumes:
    54. - /opt/jumpserver/data/guacamole-keys:/config/guacamole/keys
    55. networks:
    56. - jumpserver
    57. nginx:
    58. image: jumpserver/jms_nginx:${Version}
    59. container_name: jms_nginx
    60. restart: always
    61. tty: true
    62. depends_on:
    63. - core
    64. - koko
    65. volumes:
    66. - /opt/jumpserver/data/core-data:/opt/jumpserver/data
    67. ports:
    68. - 80:80
    69. networks:
    70. - jumpserver
    71. volumes:
    72. core-data:
    73. koko-keys:
    74. guacamole-keys:
    75. networks:
    76. jumpserver:
  4. 启动容器
docker-compose up -d
  1. 打开浏览器访问150.45和150.26,默认账号密码是admin, 在浏览器上测试数据是否会同步
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/你好赵伟/article/detail/73511
推荐阅读
相关标签
  

闽ICP备14008679号