Jumpserver之安装在CentOS主机步骤

  环境

  系统CentOS7.5

  IP:172.16.90.248

  关闭防火墙设置selinux

1
2
3
systemctl stop firewalld
setenforce 0
sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config

  一.准备Python3和Python虚拟环境

  1.1安装依赖包

1
yum -y install wget gcc epel-release git

  1.2安装Python3.6

1
yum -y install python36 python36-devel

  如果下载速度慢可以换国内源

1
2
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
yum -y install python36 python36-devel

  1.3建立Python虚拟环境

  因为 CentOS 7 自带的是 Python2, 而 Yum 等工具依赖原来的 Python, 为了不扰乱原来的环境我们来使用 Python 虚拟环境

1
2
3
cd /opt/
python3.6 -m venv py3
source /opt/py3/bin/activate

  看到下面提示代表成功,以后运行jumpserver都要先运行以上source命令,以下所有命令都是在该虚拟环境运行

 

  二.安装Jumpserver

  2.1下载或clone项目

1
2
cd /opt
git clone https://github.com/jumpserver/jumpserver.git

  2.2安装依赖RPM包

1
2
cd /opt/jumpserver/requirements
yum -y install $(cat rpm_requirements.txt)

  2.3安装Python库依赖

1
2
3
4
5
6
pip install --upgrade pip setuptools
 pip install -r requirements.txt
 
# 如果下载速度很慢, 可以换国内源
pip install --upgrade pip setuptools -i https://mirrors.aliyun.com/pypi/simple/
pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/

  2.4安装Redis,Jumpserver使用redis做cache和celery broke

1
2
3
yum -y install redis
systemctl enable redis
systemctl start redis

  2.5安装MySQL

  本教程使用 Mysql 作为数据库, 如果不使用 Mysql 可以跳过相关 Mysql 安装和配置

1
2
3
yum -y install mariadb mariadb-devel mariadb-server
systemctl enable mariadb
systemctl start mariadb

  2.6创建数据库jumpserver并授权

1
2
3
DB_PASSWORD=`cat /dev/urandom | tr -dc A-Za-z0-9 | head -c 24`
echo -e "\033[31m 你的数据库密码是 $DB_PASSWORD \033[0m"
 mysql -uroot -e "create database jumpserver default charset 'utf8'; grant all on jumpserver.* to 'jumpserver'@'127.0.0.1' identified by '$DB_PASSWORD'; flush privileges;"

  

1
2
echo -e "\033[31m 你的数据库密码是 $DB_PASSWORD \033[0m"
 你的数据库密码是 FCgdsBsyiiEdNT2BIgRTBwEv

  2.7修改Jumpserver配置文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
$ cd /opt/jumpserver
$ cp config_example.yml config.yml
 
$ SECRET_KEY=`cat /dev/urandom | tr -dc A-Za-z0-9 | head -c 50# 生成随机SECRET_KEY
$ echo "SECRET_KEY=$SECRET_KEY" >> ~/.bashrc
$ BOOTSTRAP_TOKEN=`cat /dev/urandom | tr -dc A-Za-z0-9 | head -c 16# 生成随机BOOTSTRAP_TOKEN
$ echo "BOOTSTRAP_TOKEN=$BOOTSTRAP_TOKEN" >> ~/.bashrc
 
$ 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: $DB_PASSWORD/g" /opt/jumpserver/config.yml
 
$ echo -e "\033[31m 你的SECRET_KEY是 $SECRET_KEY \033[0m"
$ echo -e "\033[31m 你的BOOTSTRAP_TOKEN是 $BOOTSTRAP_TOKEN \033[0m"
 
$ vi config.yml  # 确认内容有没有错误

  

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# SECURITY WARNING: keep the secret key used in production secret!
# 加密秘钥 生产环境中请修改为随机字符串,请勿外泄, 可使用命令生成
# $ cat /dev/urandom | tr -dc A-Za-z0-9 | head -c 49;echo
SECRET_KEY:
 
# SECURITY WARNING: keep the bootstrap token used in production secret!
# 预共享Token coco和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:
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
#
# Use Radius authorization
# 使用Radius来认证
# AUTH_RADIUS: false
# RADIUS_SERVER: localhost
# RADIUS_PORT: 1812
# RADIUS_SECRET:
 
 
# OTP settings
# OTP/MFA 配置
# OTP_VALID_WINDOW: 0
# OTP_ISSUER_NAME: Jumpserver

  

  2.8运行jumpserver

1
2
cd /opt/jumpserver/
./jms start all -d

  不报错则代表运行成功

  -d参数代表后台运行

 

  三.安装SSH Server和WebSocket Server:Coco

  3.1下载或clone项目

1
2
3
cd /opt/
source /opt/py3/bin/activate
git clone https://github.com/jumpserver/coco.git

  3.2安装依赖

1
2
3
4
5
6
$ cd /opt/coco/requirements
$ yum -y install $(cat rpm_requirements.txt)
$ pip install -r requirements.txt
 
# 如果下载速度很慢, 可以换国内源
$ pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/

  3.3修改配置文件并运行

1
2
3
4
5
6
7
$ cd /opt/coco
$ cp config_example.yml config.yml
 
$ sed -i "s/BOOTSTRAP_TOKEN: <PleasgeChangeSameWithJumpserver>/BOOTSTRAP_TOKEN: $BOOTSTRAP_TOKEN/g" /opt/coco/config.yml
$ sed -i "s/# LOG_LEVEL: INFO/LOG_LEVEL: ERROR/g" /opt/coco/config.yml
 
$ vi config.yml

  

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# 项目名称, 会用来向Jumpserver注册, 识别而已, 不能重复
# NAME: {{ Hostname }}
 
# Jumpserver项目的url, api请求注册会使用
CORE_HOST: http://127.0.0.1:8080
 
# Bootstrap Token, 预共享秘钥, 用来注册coco使用的service account和terminal
# 请和jumpserver 配置文件中保持一致,注册完成后可以删除
BOOTSTRAP_TOKEN:
 
# 启动时绑定的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

  运行

1
./cocod start -d

  

  四。安装Web Terminnal前端:Luna

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

  4.1解压Luna

1
2
3
4
cd /opt/
wget https://github.com/jumpserver/luna/releases/download/1.4.9/luna.tar.gz
tar -xf luna.tar.gz
chown -R root:root luna

  

  五.安装windows支持组件

  没有windows资产不需要安装

  

  六。配置Nginx整合组件

  6.1安装Nginx

1
2
3
4
5
6
7
8
9
10
11
12
13
14
$ yum install yum-utils
$ vi /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
 
$ yum makecache fast
$ yum install -y nginx
$ rm -rf /etc/nginx/conf.d/default.conf
$ systemctl enable nginx

  6.2准备配置文件 修改 /etc/nginx/conf.d/jumpserver.conf

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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;
    }
 
    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;
    }
}

  6.3运行

1
2
3
nginx -t
systemctl start nginx
systemctl enable nginx

  6.4开始使用Jumpserver

  使用IP访问,不要通过8080端口访问

  默认账号:admin 默认密码:admin

 

   测试连接

1
2
3
4
5
6
7
8
9
10
如果登录客户端是 macOS 或 Linux, 登录语法如下
$ ssh -p2222 admin@172.16.90.248
$ sftp -P2222 admin@172.16.90.248
密码: admin
 
如果登录客户端是 Windows, Xshell Terminal 登录语法如下
$ ssh admin@172.16.90.248 2222
$ sftp admin@172.16.90.248 2222
密码: admin
如果能登陆代表部署成功

  Jumpserver部署成功

  

 

posted @   minseo  阅读(466)  评论(0编辑  收藏  举报
编辑推荐:
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
点击右上角即可分享
微信分享提示