注意:以上组件可以通过github下载。每个组件的的下载方法,可以查看官方文档。注意要保证各组件的版本一致。
注意:jumpserver_packge-v1.5.6.tar.gz文件是我自己打的包,里面包含了用到的各组件(guacamole组件除外),版本均为1.5.6。
建议使用新创建的centos7操作系统,如果主机已经安装过了jumpserver,一定要清理干净,清理mysql数据库,清理redis,还有.bashrc文件中记录的SECRET_KEY、BOOTSTRAP_TOKEN。
# 配置好yum源。
# yum install -y python3
# yum install mariadb-server
# yum install nginx
# yum install redis
# systemctl start mariadb
# systemctl start redis
# mkdir /opt
# python3 -m venv /opt/py3
# echo 'source /opt/py3/bin/activate' >> /root/.bashrc
# source /opt/py3/bin/activate
由于jumpserver有很多依赖组件,每个组件都有自己的版本,建议使用同样的版本。上传jumpserver_packge-v1.5.6.tar.gz
包到/root目录下。
# mysql
> create database jumpserver default charset 'utf8';
> grant all on jumpserver.* to [email protected] identified by 'root123';
> grant all on jumpserver.* to jumpserver@'localhost' identified by 'root123';
注意:一定要保证数据库的字符集为utf-8
,否则登录jumpserver的时候,由于字符集的问题,会无法登陆。
# cd /root
# tar -xvf jumpserver_packge-v1.5.6.tar.gz
# tar -xvf /root/jumpserver_packge/jumpserver.tar.gz -C /opt
# 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: root123/g" /opt/jumpserver/config.yml
# cd /opt/jumpserver/requirements
# yum install -y $(cat rpm_requirements.txt)
# pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/
# cd /opt/jumpserver
# ./jms start -d
注意:安装python依赖的时候,可能会报错:
Feature
模块失败。原因是,setuptools库的版本太高。新版本中已经没有了Feature模块。解决办法是降低setuptools库的版本。操作方法如下:
python-gssapi
库失败。由于python依赖包的关系,可以将requirements.txt文件中的python-gssapi临时注释掉。单独安装python-gssapi。
注意:最新版本的coco组件,换成了koko,两者的功能一样,使用go语言编写。下载的时候,不要下载错了。
# tar -xvf /root/jumpserver_packge/koko-master-linux-amd64.tar.gz -C /opt
# cd /opt/kokodir
# chown -R root:root /opt/kokodir
# cp config_example.yml config.yml
# 需要保证config.yml中的BOOTSTRAP_TOKEN和jumpserver/config.yml里面获取, 保证一致
# sed -i "s/BOOTSTRAP_TOKEN:/BOOTSTRAP_TOKEN: $BOOTSTRAP_TOKEN/g" /opt/kokodir/config.yml
# ./koko -d
guacamole是一种HTML5 Web应用程序,可使用远程桌面协议(例如VNC或RDP)提供对桌面环境的访问。单步安装比较复杂,建议使用docker部署。需要单独部署的话可以参考官方文档。
# 安装docker-ce。
# yum install -y yum-utils device-mapper-persistent-data lvm2
# yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
# yum makecache fast
# yum -y install docker-ce
# systemctl start docker
# 启动jms_guacamole容器。
# docker run --name jms_guacamole -d -p 127.0.0.1:8081:8080 -e JUMPSERVER_SERVER=http://[XXXXXXXXXX]:8080 -e BOOTSTRAP_TOKEN=[XXXXXXXXXXXXXX] wojiushixiaobai/jms_guacamole:1.5.6
# 注意替换JUMPSERVER_SERVER和BOOTSTRAP_TOKEN。
# tar -xvf /root/jumpserver_packge/luna.tar.gz -C /opt
# chown -R root:root /opt/luna
建议将/etc/nginx/nginx.conf
中的server字段中内容删除,或者修改部分配置。创建一个新的配置文件,配置文件内容如下所示:
# vim /etc/nginx/conf.d/jumpserver.conf
server {
listen 80;
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 /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 / {
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;
}
}
# nginx -t
# systemctl start nginx