1. JumpServer概述
-
JumpServer是全球首款完全开源的堡垒机, 使用GNU GPL v2.0开源协议, 是符合4A的专业运维审计系统。
-
JumpServer使用Python/Django进行开发, 遵循Web 2.0规范, 配备了业界领先的Web Terminal解决方案, 交互界面美观、用户体验好。
-
JumpServer采纳分布式架构, 支持多机房跨区域部署, 中心节点提供API, 各机房部署登录节点, 可横向扩展、无并发访问限制。
-
JumpServer现已支持管理 SSH、Telnet、RDP、VNC 协议资产。
jumpserver特点:
1)开源
零门槛,线上快速获取和安装
2)分布式
轻松支持大规模并发访问
3)云端存储
审计录像云端存储,永不丢失
4)无插件
仅需浏览器,极致的Web Terminal使用体验
5)多云支持
一套系统,同时管理不同云上面的资产
6)多租户
一套系统,多个子公司和部门同时使用
2. 环境准备
-
本次采用Ubuntu22.04操作系统;
-
提前安装好docker环境;
参考:https://www.cnblogs.com/Xneat/p/18369220
docker version
2.1 拉取jumpserver镜像
[root@jumpserver-20 ~]$ docker pull jumpserver/jms_all:latest
[root@jumpserver-20 ~]$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
jumpserver/jms_all latest 71066291bf30 13 days ago 2.11GB
2.2 安装mysql
安装指定版本mysql:
[root@jumpserver-20 ~]$ apt search mysql-server
[root@jumpserver-20 ~]$ apt-get install mysql-server-8.0
安装完成后,MySQL服务会自动启动,未启动则使用以下命令启动MySQL服务:
并且设置MySQL为开机自启动:
[root@jumpserver-20 ~]$ systemctl start mysql && systemctl enable mysql
注意:配置8.0版本参考:我这里通过这种方式没有实现所有IP都能访问;我是通过直接修改配置文件才实现的,MySQL8.0版本把配置文件 my.cnf
拆分成mysql.cnf
和mysqld.cnf
,我们需要修改的是mysqld.cnf
文件:
[root@jumpserver-20 ~]$ vim /etc/mysql/mysql.conf.d/mysqld.cnf
# 修改 bind-address,保存后重启MySQL即可。
bind-address = 0.0.0.0
# 重启MySQL重新加载一下配置:
[root@jumpserver-20 ~]$ systemctl restart mysql
2.3 配置MysSQL数据库配置
# 默认没有密码回车直接进入
[root@jumpserver-20 ~]$ mysql
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';
Query OK, 0 rows affected (0.00 sec) # 设置root新密码
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql>create database jumpserver default charset 'utf8' collate 'utf8_bin'; # 创建数据库
mysql>CREATE USER jumpserver@'%' IDENTIFIED BY '123456'; # 创建用户
mysql>GRANT ALL ON jumpserver.* TO jumpserver@'%'; # 授权
mysql> grant all on jumpserver.* to 'jumpserver'@'localhost' identified by '123456'; Query OK, 0 rows affected (0.00 sec) # 如果执行上述命令本机如无法正常登录,执行该命令就好。
# 测试授权用户是否有权限连接
[root@jumpserver-20 ~]$ mysql -ujumpserver -p123456 -h10.0.0.20
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.39-0ubuntu0.22.04.1 (Ubuntu)
Copyright (c) 2000, 2024, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> exit;
2.4 安装redis
[root@jumpserver-20 ~]$ apt-get install redis
[root@jumpserver-20 ~]$ redis-server -v
Redis server v=6.0.16 sha=00000000:0 malloc=jemalloc-5.2.1 bits=64 build=a3fdef44459b3ad6
redis默认配置文件在:/etc/redis/redis.conf
# 修改监听地址为0.0.0.0
[root@jumpserver-20 ~]$sed -i 's/^bind .*/bind 0.0.0.0/' /etc/redis/redis.conf
[root@jumpserver-20 ~]$egrep ^bind /etc/redis.conf
bind 0.0.0.0
# 设置redis连接密码
[root@jumpserver-20 ~]$ sed -i 's/^#\s*requirepass .*/requirepass 123456/' /etc/redis/redis.conf
[root@jumpserver-20 ~]$ egrep ^requirepass /etc/redis.conf
requirepass 123456
# 重启并且设置开机自启
[root@jumpserver-20 ~]$ systemctl restart redis && systemctl enable redis
2.5 Linux生成随机加密秘钥
[root@jumpserver-20 ~]$ tee /root/key.sh <<-'EOF'
#/bin/bash
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
EOF
# 执行脚本获取key及token,默认两个会保存在这个文件下~/.bashrc。
[root@jumpserver-20 ~]$ chmod +x sh.key && sh key.sh
u6kNhR1UK5vrUeFZUU5rY0xyh6TmdXRIyhI8Z5Ot6uKQynFwyd
52tbRM1daUU4i2oN
3. 启动docker镜像
3.1 启动jumpserver镜像
docker run --name jumpserver01 -d \
-v /opt/jumpserver/data/media:/opt/jumpserver/data/media \
-p 80:80 \
-p 2222:2222 \
-e SECRET_KEY=u6kNhR1UK5vrUeFZUU5rY0xyh6TmdXRIyhI8Z5Ot6uKQynFwyd \
-e BOOTSTRAP_TOKEN=52tbRM1daUU4i2oN \
-e DB_HOST=10.0.0.20 \
-e DB_PORT=3306 \
-e DB_USER=jumpserver \
-e DB_PASSWORD=123456 \
-e DB_NAME=jumpserver \
-e REDIS_HOST=10.0.0.20 \
-e REDIS_PORT=6379 \
-e REDIS_PASSWORD=123456 \
jumpserver/jms_all:latest
检查启动状态
# 检查日志是否报错
[root@jumpserver-20 ~]$ docker logs jumpserver01
3.2 访问JumpServer的Web
默认密码均为:admin
至此jumpserver安装完成。
标签:20,部署,0.0,redis,jumpserver,mysql,Docker,root From: https://www.cnblogs.com/Xneat/p/18370040