由于来源身份不明、越权操作、密码泄露、数据被窃、违规操作等因素都可能会使运营的业务系统面临严重威胁,一旦发生事故,如果不能快速定位事故原因,运维人员往往就会背黑锅。几种常见的运维人员背黑锅场景:
1)由于不明身份利用远程运维通道攻击服务器造成业务系统出现异常,但是运维人员无法明确攻击来源,那么领导很生气、后果很严重;
2)只有张三能管理的服务器,被李四登录过并且做了违规操作,但是没有证据是李四登录的,那么张三只能背黑锅了;
3)运维人员不小心泄露了服务器的密码。一旦发生安全事故,那么后果不堪设想;
4)某服务器的重要数据被窃。但是数据文件无法挽回,那么面临的是无法估量的经济损失;
1.Jumpserver *
2.CrazyEye *
3.麒麟开源堡垒机 *
4.开源堡垒机GateOne
5.堡垒机xrdp:
JumpServer 是全球首款完全开源的堡垒机, 使用 GNU GPL v2.0 开源协议, 是符合 4A 的专业运维审计系统。
JumpServer 使用 Python / Django 进行开发, 遵循 Web 2.0 规范, 配备了业界领先的 Web Terminal 解决方案, 交互界面美观、用户体验好。
JumpServer 采纳分布式架构, 支持多机房跨区域部署, 中心节点提供 API, 各机房部署登录节点, 可横向扩展、无并发访问限制。
JumpServer 现已支持管理 SSH、 Telnet、 RDP、 VNC 协议资产。
(jumpserver堡垒机很多都是docker,但当发生问题时不容易排错,所以在真实的工作环境中还是通过源码二进制安装的好一点更适应于真实的生产环境中)
jumpserver官网地址:https://github.com/jumpserver/jumpserver/tree/2.0.1
python官网地址:https://www.python.org/ftp/python/3.6.1/
yum -y install wget lrzsz xz gcc git epel-release python-pip python-devel mysql-devel automake autoconf sqlite-devel zlib-devel openssl-devel sshpass readline-devel
安装python
#因为python3.6指支持jumpserver 2.0.1版本以下的环境所以请手动到github官网下载安装
#上传包Python-3.6.1.tar.xz
tar xf Python-3.6.1.tar.xz
mv Python-3.6.1 /opt
cd /opt/Python-3.6.1
./configure
make && make install #编译并安装
建立 Python 虚拟环境
cd /opt
python3.6 -m venv py3
source /opt/py3/bin/activate
在Github上下载 jumpserver包并上传
下载地址在上方:
jumpserver-2.0.1.zip
unzip jumpserver-2.0.1.zip
mv jumpserver-2.0.1.zip /opt/jumpserver
安装依赖
cd /opt/jumpserver/requirements
yum -y install $(cat rpm_requirements.txt)
安装Python依赖
pip install --upgrade pip setuptools
pip install -r requirements.txt #(最好使用本地的requirements.txt否则容易造成环境出错)
阿里云源下载(更快)
pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/
安装 Redis, Jumpserver 使用 Redis 做 cache 和 celery broke
yum -y install redis
systemctl start redis
安装 MySQL
yum -y install mariadb mariadb-devel mariadb-server
systemctl start mariadb
创建数据库 Jumpserver 并授权
DB_PASSWORD=`cat /dev/urandom | tr -dc A-Za-z0-9 | head -c 24`
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;"
修改 Jumpserver 配置文件
cd /opt/jumpserver/
cp config_example.yml config.yml
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
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
8、运行 Jumpserver
cd /opt/jumpserver
./jms start all -d
如果报错(ImportError: cannot import name ‘byte_string’)请执行以下操作:
这是因为依赖包的版本问题
卸载依赖包
pip uninstall pycrypto
pip uninstall pycryptodemo
重新安装依赖包
pip install pycrypto
如果报错(django.db.utils.OperationalError: (2006, “Access denied for user ‘jumpserver’@‘localhost’ (using password: YES)”))请执行:
创数据库时 密码自己创 然后在jumpserver配置文件 DB_PASSWORD 写成自己创的密码
测试查看一下端口是 :8080
因为没有安装nginx web界面和相关的配套组件所以这个界面
Docker 部署 KoKo 组件
yum -y install docker #安装 docker (如已安装请跳过)
systemctl start docker #开启
docker run --name jms_koko -d \ #创建
-p 2222:2222 \
-p 127.0.0.1:5000:5000 \
-e CORE_HOST=http://192.168.40.111:8080 \ #记得换成自己的ip地址
-e BOOTSTRAP_TOKEN=99a0hu9pqc5U9qBN \
-e LOG_LEVEL=ERROR \
--privileged=true \
--restart=always \
jumpserver/jms_koko:v2.4.0
Docker部署Guacamole 组件
docker run --name jms_guacamole -d \
-p 127.0.0.1:8081:8080 \
-e JUMPSERVER_SERVER=http://192.168.40.111:8080 \ #记得换成自己的ip地址
-e BOOTSTRAP_TOKEN=abcdefg1234 \
-e GUACAMOLE_LOG_LEVEL=ERROR \
jumpserver/jms_guacamole:v2.4.0
下载 Lina 组件
因为Lina需要nginx的授权组所以先安装nginx
yum -y install nginx
cd /opt
wget https://github.com/jumpserver/lina/releases/download/v2.4.0/lina-v2.4.0.tar.gz
tar -xf lina-v2.4.0.tar.gz
mv lina-v2.4.0 lina
chown -R nginx:nginx lina
下载 Luna 组件
cd /opt
wget https://github.com/jumpserver/luna/releases/download/v2.4.0/luna-v2.4.0.tar.gz
tar -xf luna-v2.4.0.tar.gz
mv luna-v2.4.0 luna
chown -R nginx:nginx luna
配置 Nginx 整合各组件
yum -y install nginx
echo > /etc/nginx/conf.d/default.conf
vi /etc/nginx/conf.d/jumpserver.conf
server {
listen 80;
client_max_body_size 100m; # 录像及文件上传大小限制
location /ui/ {
try_files $uri / /index.html;
alias /opt/lina/;
}
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 /koko/ {
proxy_pass http://localhost:5000;
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 /guacamole/ {
proxy_pass http://localhost:8081/;
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 /ws/ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://localhost:8070;
proxy_http_version 1.1;
proxy_buffering off;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
location /api/ {
proxy_pass http://localhost:8080;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /core/ {
proxy_pass http://localhost:8080;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location / {
rewrite ^/(.*)$ /ui/$1 last;
}
}
删除nginx.conf配置文件中的server模块
systemctl start nginx
nginx -t
nginx -s reload
测试一下:因为绑定了nginx所以80端口就可以访问了
登录以后的界面
参考资料:git 官网文档 https://github.com/jumpserver/jumpserver