编译文档

目前 JumpServer 不支持在 Windows 平台编译

架构图

!架构图

JumpServer 分为多个组件, 大致的架构如上图所示. 其中 LinaLuna 为纯静态文件, 最终由 nginx 整合

Core

Core 是 JumpServer 的核心组件, 由 Django 二次开发而来, 内置了 Gunicorn Celery Beat Flower Daphne 服务

环境要求

CorePythonMySQLMariaDBRedis
v1.0 - v2.6= 3.6>= 5>= 5
>= 2.6>= 3.6>= 5.7>= 10.2>= 5

下载源代码

可以从 Github 网站上获取最新的 Release 副本。这些版本是最新代码的稳定快照,从项目网站下载的源将采用 .tar.gz 存档的形式,通过命令行中提取该存档:

  1. tar -xf jumpserver-v2.9.2.tar.gz
  2. cd jumpserver-v2.9.2
  1. ls -l requirements/
  1. requirements/ # 对应操作系统需要的依赖包
  2. ├── alpine_requirements.txt # Alpine
  3. ├── deb_buster_requirements.txt # Debian 10
  4. ├── deb_requirements.txt # 基于 Debian 的发行版(如: Ubuntu)
  5. ├── issues.txt # macOS 一些问题及解决方案
  6. ├── mac_requirements.txt # macOS
  7. ├── requirements.txt # python
  8. └── rpm_requirements.txt # 基于 RedHat 的发行版(如: CentOS)
OSCommand
macOSbrew install -y $(cat mac_requirements.txt)
Alpineapk add $(cat alpine_requirements.txt)
Ubuntu / Debianapt-get install -y $(cat deb_requirements.txt)
CentOS / RedHatapt-get install -y $(cat deb_requirements.txt)

安装 Python3

Python 网站部署 Python3, 请根据 环境要求, 通过命令行中判断是否安装完成:

  1. python3
  1. Python 3.6.8 (default, Nov 16 2020, 16:55:22)
  2. [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux
  3. Type "help", "copyright", "credits" or "license" for more information.
  4. >>>

安装 python 依赖

推荐为 JumpServer 项目单独创建 python3 虚拟环境

  1. python3 -m venv ~/project/jms_py3
  2. source ~/project/jms_py3

每次运行项目都需要先执行 source ~/project/jms_py3 载入此环境. (jms_py3) [root@jms-test ~]#

  1. pip install -r requirements.txt

修改配置文件

  1. cp config_example.yml config.yml
  2. vi config.yml
  1. # SECURITY WARNING: keep the secret key used in production secret!
  2. # 加密秘钥 生产环境中请修改为随机字符串,请勿外泄, 可使用命令生成
  3. # $ cat /dev/urandom | tr -dc A-Za-z0-9 | head -c 49;echo
  4. SECRET_KEY: **************** # 必填项
  5. # SECURITY WARNING: keep the bootstrap token used in production secret!
  6. # 预共享Token coco和guacamole用来注册服务账号,不在使用原来的注册接受机制
  7. BOOTSTRAP_TOKEN: *********** # 必填项
  8. # Development env open this, when error occur display the full process track, Production disable it
  9. # DEBUG 模式 开启DEBUG后遇到错误时可以看到更多日志
  10. DEBUG: true # 开发建议打开 DEBUG, 生产环境应该关闭
  11. # DEBUG, INFO, WARNING, ERROR, CRITICAL can set. See https://docs.djangoproject.com/en/1.10/topics/logging/
  12. # 日志级别
  13. LOG_LEVEL: DEBUG # 开发建议设置 DEBUG, 生产环境推荐使用 ERROR
  14. # LOG_DIR:
  15. # Session expiration setting, Default 24 hour, Also set expired on on browser close
  16. # 浏览器Session过期时间,默认24小时, 也可以设置浏览器关闭则过期
  17. # SESSION_COOKIE_AGE: 86400
  18. SESSION_EXPIRE_AT_BROWSER_CLOSE: true # 浏览器关闭 session 过期
  19. # Database setting, Support sqlite3, mysql, postgres ....
  20. # 数据库设置
  21. # See https://docs.djangoproject.com/en/1.10/ref/settings/#databases
  22. # SQLite setting:
  23. # 使用单文件sqlite数据库
  24. # DB_ENGINE: sqlite3
  25. # DB_NAME:
  26. # MySQL or postgres setting like:
  27. # 使用Mysql作为数据库
  28. DB_ENGINE: mysql
  29. DB_HOST: 127.0.0.1 # 自行配置 数据库相关
  30. DB_PORT: 3306
  31. DB_USER: jumpserver
  32. DB_PASSWORD: ********
  33. DB_NAME: jumpserver
  34. # When Django start it will bind this host and port
  35. # ./manage.py runserver 127.0.0.1:8080
  36. # 运行时绑定端口, 将会使用 0.0.0.0:8080 0.0.0.0:8070 端口
  37. HTTP_BIND_HOST: 0.0.0.0
  38. HTTP_LISTEN_PORT: 8080
  39. WS_LISTEN_PORT: 8070
  40. # Use Redis as broker for celery and web socket
  41. # Redis配置
  42. REDIS_HOST: 127.0.0.1 # 自行配置 Redis 相关
  43. REDIS_PORT: 6379
  44. REDIS_PASSWORD: ********
  45. # REDIS_DB_CELERY: 3
  46. # REDIS_DB_CACHE: 4
  47. # Use OpenID Authorization
  48. # 使用 OpenID 进行认证设置
  49. # AUTH_OPENID: False # True or False
  50. # BASE_SITE_URL: None
  51. # AUTH_OPENID_CLIENT_ID: client-id
  52. # AUTH_OPENID_CLIENT_SECRET: client-secret
  53. # AUTH_OPENID_PROVIDER_ENDPOINT: https://op-example.com/
  54. # AUTH_OPENID_PROVIDER_AUTHORIZATION_ENDPOINT: https://op-example.com/authorize
  55. # AUTH_OPENID_PROVIDER_TOKEN_ENDPOINT: https://op-example.com/token
  56. # AUTH_OPENID_PROVIDER_JWKS_ENDPOINT: https://op-example.com/jwks
  57. # AUTH_OPENID_PROVIDER_USERINFO_ENDPOINT: https://op-example.com/userinfo
  58. # AUTH_OPENID_PROVIDER_END_SESSION_ENDPOINT: https://op-example.com/logout
  59. # AUTH_OPENID_PROVIDER_SIGNATURE_ALG: HS256
  60. # AUTH_OPENID_PROVIDER_SIGNATURE_KEY: None
  61. # AUTH_OPENID_SCOPES: "openid profile email"
  62. # AUTH_OPENID_ID_TOKEN_MAX_AGE: 60
  63. # AUTH_OPENID_ID_TOKEN_INCLUDE_CLAIMS: True
  64. # AUTH_OPENID_USE_STATE: True
  65. # AUTH_OPENID_USE_NONCE: True
  66. # AUTH_OPENID_SHARE_SESSION: True
  67. # AUTH_OPENID_IGNORE_SSL_VERIFICATION: True
  68. # AUTH_OPENID_ALWAYS_UPDATE_USER: True
  69. # Use Radius authorization
  70. # 使用Radius来认证
  71. # AUTH_RADIUS: false
  72. # RADIUS_SERVER: localhost
  73. # RADIUS_PORT: 1812
  74. # RADIUS_SECRET:
  75. # CAS 配置
  76. # AUTH_CAS': False,
  77. # CAS_SERVER_URL': "http://host/cas/",
  78. # CAS_ROOT_PROXIED_AS': 'http://jumpserver-host:port',
  79. # CAS_LOGOUT_COMPLETELY': True,
  80. # CAS_VERSION': 3,
  81. # LDAP/AD settings
  82. # LDAP 搜索分页数量
  83. # AUTH_LDAP_SEARCH_PAGED_SIZE: 1000
  84. #
  85. # 定时同步用户
  86. # 启用 / 禁用
  87. # AUTH_LDAP_SYNC_IS_PERIODIC: True
  88. # 同步间隔 (单位: 时) (优先)
  89. # AUTH_LDAP_SYNC_INTERVAL: 12
  90. # Crontab 表达式
  91. # AUTH_LDAP_SYNC_CRONTAB: * 6 * * *
  92. #
  93. # LDAP 用户登录时仅允许在用户列表中的用户执行 LDAP Server 认证
  94. # AUTH_LDAP_USER_LOGIN_ONLY_IN_USERS: False
  95. #
  96. # LDAP 认证时如果日志中出现以下信息将参数设置为 0 (详情参见:https://www.python-ldap.org/en/latest/faq.html)
  97. # In order to perform this operation a successful bind must be completed on the connection
  98. # AUTH_LDAP_OPTIONS_OPT_REFERRALS: -1
  99. # OTP settings
  100. # OTP/MFA 配置
  101. # OTP_VALID_WINDOW: 0
  102. # OTP_ISSUER_NAME: Jumpserver
  103. # Perm show single asset to ungrouped node
  104. # 是否把未授权节点资产放入到 未分组 节点中
  105. # PERM_SINGLE_ASSET_TO_UNGROUP_NODE: False
  106. #
  107. # 同一账号仅允许在一台设备登录
  108. # USER_LOGIN_SINGLE_MACHINE_ENABLED: False
  109. #
  110. # 启用定时任务
  111. # PERIOD_TASK_ENABLE: True
  112. #
  113. # 启用二次复合认证配置
  114. # LOGIN_CONFIRM_ENABLE: False
  115. #
  116. # Windows 登录跳过手动输入密码
  117. # WINDOWS_SKIP_ALL_MANUAL_PASSWORD: False

启动 Core

后台运行可以加 -d, ./jmsctl.sh start all -d

  1. ./jmsctl.sh start all

Lina

环境要求

LinaNode
all= 10

下载源代码

可以从 Github 网站上获取最新的 Release 副本。这些版本是最新代码的稳定快照,从项目网站下载 Source code.tar.gz 源代码,通过命令行中提取该存档:

  1. tar -xf lina-v2.9.2.tar.gz
  2. cd lina-v2.9.2

安装 Node

Node 官方网站参考文档部署 Node.js, 请根据 环境要求, 通过命令行中判断是否安装完成:

  1. node -v

v10.24.1

安装依赖

  1. npm install -g yarn
  2. yarn install

修改配置文件

  1. vi .env.development
  1. # 全局环境变量 请勿随意改动
  2. ENV = 'development'
  3. # base api
  4. VUE_APP_BASE_API = ''
  5. VUE_APP_PUBLIC_PATH = '/ui/'
  6. # vue-cli uses the VUE_CLI_BABEL_TRANSPILE_MODULES environment variable,
  7. # to control whether the babel-plugin-dynamic-import-node plugin is enabled.
  8. # It only does one thing by converting all import() to require().
  9. # This configuration can significantly increase the speed of hot updates,
  10. # when you have a large number of pages.
  11. # Detail: https://github.com/vuejs/vue-cli/blob/dev/packages/@vue/babel-preset-app/index.js
  12. VUE_CLI_BABEL_TRANSPILE_MODULES = true
  13. # External auth
  14. VUE_APP_LOGIN_PATH = '/core/auth/login/'
  15. VUE_APP_LOGOUT_PATH = '/core/auth/logout/'
  16. # Dev server for core proxy
  17. VUE_APP_CORE_HOST = 'http://localhost:8080' # 修改成 Core 的 url 地址
  18. VUE_APP_ENV = 'development'

运行 Lina

  1. yarn serve

构建 Lina

构建完成后的 lina 包为 html 文件, 可以直接移到到 nginx 服务器

  1. yarn build

Luna

环境要求

LunaNode
all= 10

下载源代码

可以从 Github 网站上获取最新的 Release 副本。这些版本是最新代码的稳定快照,从项目网站下载 Source code.tar.gz 源代码,通过命令行中提取该存档:

  1. tar -xf luna-v2.9.2.tar.gz
  2. cd luna-v2.9.2

安装 Node

Node 官方网站参考文档部署 Node.js, 请根据 环境要求, 通过命令行中判断是否安装完成:

  1. node -v

v10.24.1

安装依赖

  1. npm -i
  2. npm rebuild node-sass

修改配置文件

  1. vi proxy.conf.json
  1. {
  2. "/api": {
  3. "target": "http://127.0.0.1:8080", # Core 地址
  4. "secure": false # https ssl 需要开启
  5. },
  6. "/koko": {
  7. "target": "http://127.0.0.1:5000", # KoKo 地址
  8. "secure": false,
  9. "ws": true
  10. },
  11. "/media/": {
  12. "target": "http://127.0.0.1:8080", # Core 地址
  13. "secure": false
  14. },
  15. "/guacamole/": {
  16. "target": "http://127.0.0.1:8081", # Guacamole 地址
  17. "secure": false,
  18. "ws": true,
  19. "pathRewrite": {
  20. "^/guacamole": ""
  21. }
  22. }
  23. }

运行 Luna

  1. ng serve

构建 Luna

可以加 -prod 来进行生产构建 ng build -prod

  1. ng build

KoKo

Koko 是 Go 版本的 coco;重构了 coco 的 SSH/SFTP 服务和 Web Terminal 服务

环境要求

KoKoGo
v1.0 - v2.6= 1.12
>= 2.6= 1.15

下载源代码

可以从 Github[koko] 网站上获取最新的 Release 副本。这些版本是最新代码的稳定快照,从项目网站下载 Source code.tar.gz 源代码,通过命令行中提取该存档:

OSArchName
Linuxamd64koko-v2.9.2-linux-amd64.tar.gz
macOSamd64koko-v2.9.2-darwin-amd64.tar.gz
  1. tar -xf koko-v2.9.2.tar.gz
  2. cd koko-v2.9.2

安装 Go

Go 官方网站参考文档部署 golang, 请根据 环境要求, 通过命令行中判断是否安装完成:

  1. go version

go version go1.15 linux/amd64

编译:

OSArchCommand
Linuxamd64make linux
macOSamd64make darwin
  1. make

修改配置文件

  1. cp config_example.yml config.yml
  2. vi config.yml
  1. # 项目名称, 会用来向Jumpserver注册, 识别而已, 不能重复
  2. # NAME:
  3. # Jumpserver项目的url, api请求注册会使用
  4. CORE_HOST: http://127.0.0.1:8080 # Core 的地址
  5. # Bootstrap Token, 预共享秘钥, 用来注册coco使用的service account和terminal
  6. # 请和jumpserver 配置文件中保持一致,注册完成后可以删除
  7. BOOTSTRAP_TOKEN: ******** # 和 Core config.yml 的值保持一致
  8. # 启动时绑定的ip, 默认 0.0.0.0
  9. BIND_HOST: 0.0.0.0
  10. # 监听的SSH端口号, 默认2222
  11. SSHD_PORT: 2222 # 使用 0.0.0.0:2222
  12. # 监听的HTTP/WS端口号,默认5000
  13. HTTPD_PORT: 5000 # 使用 0.0.0.0:5000
  14. # 项目使用的ACCESS KEY, 默认会注册,并保存到 ACCESS_KEY_STORE中,
  15. # 如果有需求, 可以写到配置文件中, 格式 access_key_id:access_key_secret
  16. # ACCESS_KEY: null
  17. # ACCESS KEY 保存的地址, 默认注册后会保存到该文件中
  18. # ACCESS_KEY_FILE: data/keys/.access_key
  19. # 设置日志级别 [DEBUG, INFO, WARN, ERROR, FATAL, CRITICAL]
  20. LOG_LEVEL: DEBUG # 开发建议设置 DEBUG, 生产环境推荐使用 ERROR
  21. # SSH连接超时时间 (default 15 seconds)
  22. # SSH_TIMEOUT: 15
  23. # 语言 [en,zh]
  24. # LANGUAGE_CODE: zh
  25. # SFTP的根目录, 可选 /tmp, Home其他自定义目录
  26. # SFTP_ROOT: /tmp
  27. # SFTP是否显示隐藏文件
  28. # SFTP_SHOW_HIDDEN_FILE: false
  29. # 是否复用和用户后端资产已建立的连接(用户不会复用其他用户的连接)
  30. # REUSE_CONNECTION: true
  31. # 资产加载策略, 可根据资产规模自行调整. 默认异步加载资产, 异步搜索分页; 如果为all, 则资产全部加载, 本地搜索分页.
  32. # ASSET_LOAD_POLICY:
  33. # zip压缩的最大额度 (单位: M)
  34. # ZIP_MAX_SIZE: 1024M
  35. # zip压缩存放的临时目录 /tmp
  36. # ZIP_TMP_PATH: /tmp
  37. # 向 SSH Client 连接发送心跳的时间间隔 (单位: 秒),默认为30, 0则表示不发送
  38. # CLIENT_ALIVE_INTERVAL: 30
  39. # 向资产发送心跳包的重试次数,默认为3
  40. # RETRY_ALIVE_COUNT_MAX: 3
  41. # 会话共享使用的类型 [local, redis], 默认local
  42. # SHARE_ROOM_TYPE: local
  43. # Redis配置
  44. # REDIS_HOST: 127.0.0.1 # 如果需要部署多个 koko, 需要通过 redis 来保持会话
  45. # REDIS_PORT: 6379
  46. # REDIS_PASSWORD:
  47. # REDIS_CLUSTERS:
  48. # REDIS_DB_ROOM:

启动 KoKo

后台运行可以加 -d, ./koko -d

  1. ./koko

Guacamole

环境要求

JumpServerOpenJDK
All= 1.8

等待更新..

Nginx

Nginx 官方网站上获取 Nginx 的最新发行版本 linux_packages, 通过命令行验证安装是否完成:

  1. nginx -v

nginx version: nginx/1.18.0

整合 JumpServer

  1. vi jumpserver.conf
  1. server {
  2. listen 80;
  3. # server_name _;
  4. client_max_body_size 5000m; 文件大小限制
  5. # Luna 配置
  6. location /luna/ {
  7. proxy_pass http://luna:4200;
  8. }
  9. # Core data 静态资源
  10. location /media/replay/ {
  11. add_header Content-Encoding gzip;
  12. root /data/;
  13. }
  14. location /media/ {
  15. root /data/;
  16. }
  17. location /static/ {
  18. root /data/;
  19. }
  20. # Koko 配置
  21. location /koko/ {
  22. proxy_pass http://koko:5000;
  23. proxy_set_header X-Real-IP $remote_addr;
  24. proxy_set_header Host $host;
  25. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  26. proxy_http_version 1.1;
  27. proxy_buffering off;
  28. proxy_set_header Upgrade $http_upgrade;
  29. proxy_set_header Connection "upgrade";
  30. }
  31. # Guacamole 配置
  32. location /guacamole/ {
  33. proxy_pass http://guacamole:8081/;
  34. proxy_buffering off;
  35. proxy_request_buffering off;
  36. proxy_http_version 1.1;
  37. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  38. proxy_set_header Upgrade $http_upgrade;
  39. proxy_set_header Connection $http_connection;
  40. proxy_ignore_client_abort on;
  41. proxy_connect_timeout 600;
  42. proxy_send_timeout 600;
  43. proxy_read_timeout 600;
  44. send_timeout 6000;
  45. }
  46. # Core 配置
  47. location /ws/ {
  48. proxy_pass http://core:8070;
  49. proxy_set_header X-Real-IP $remote_addr;
  50. proxy_set_header Host $host;
  51. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  52. proxy_http_version 1.1;
  53. proxy_buffering off;
  54. proxy_set_header Upgrade $http_upgrade;
  55. proxy_set_header Connection "upgrade";
  56. }
  57. location /api/ {
  58. proxy_pass http://core:8080;
  59. proxy_set_header X-Real-IP $remote_addr;
  60. proxy_set_header Host $host;
  61. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  62. }
  63. location /core/ {
  64. proxy_pass http://core:8080;
  65. proxy_set_header X-Real-IP $remote_addr;
  66. proxy_set_header Host $host;
  67. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  68. }
  69. # 前端 Lina
  70. location /ui/ {
  71. proxy_pass http://lina:9528;
  72. proxy_set_header X-Real-IP $remote_addr;
  73. proxy_set_header Host $host;
  74. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  75. }
  76. location / {
  77. rewrite ^/(.*)$ /ui/$1 last;
  78. }
  79. }
  1. nginx -t
  1. nginx -s reload