CentOS7安装jumpserver

IT
IT
IT
335
文章
1
评论
2020年4月17日16:29:13 评论 1,184 7849字阅读26分9秒

配置防火墙

[root@jenkins ~]# systemctl start firewalld
[root@jenkins ~]# firewall-cmd --zone=public --add-port=80/tcp --permanent
success
[root@jenkins ~]# firewall-cmd --zone=public --add-port=2222/tcp --permanent
success
[root@jenkins ~]# --permanent
[root@jenkins ~]# firewall-cmd --reload 
success
[root@jenkins ~]# setenforce 0
[root@jenkins ~]# sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config

安装依赖

[root@jenkins ~]# yum -y install wget gcc epel-release git

安装 Redis, JumpServer 使用 Redis 做 cache 和 celery broke

[root@jenkins ~]#  yum -y install redis
[root@jenkins ~]# systemctl enable redis
Created symlink from /etc/systemd/system/multi-user.target.wants/redis.service to /usr/lib/systemd/system/redis.service.
[root@jenkins ~]# systemctl start redis

安装 MySQL, 如果不使用 Mysql 可以跳过相关 Mysql 安装和配置, 支持sqlite3, mysql, postgres等

[root@jenkins ~]# yum -y install mariadb mariadb-devel mariadb-server MariaDB-shared
[root@jenkins ~]# systemctl enable mariadb
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
[root@jenkins ~]# systemctl start mariadb

创建数据库 JumpServer 并授权

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

安装 Nginx, 用作代理服务器整合 JumpServer 与各个组件

[root@jenkins ~]# vi /etc/yum.repos.d/nginx.repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=0
enabled=1
[root@jenkins ~]# yum -y install nginx
[root@jenkins ~]# systemctl enable nginx
Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.

安装 Python3.6

[root@jenkins ~]# yum -y install python36 python36-devel

配置并载入 Python3 虚拟环境

[root@jenkins ~]# cd /opt
[root@jenkins opt]# python3.6 -m venv py3 
[root@jenkins opt]# source /opt/py3/bin/activate

下载 JumpServer

(py3) [root@jenkins opt]# cd /opt/
(py3) [root@jenkins opt]# git clone --depth=1 https://github.com/jumpserver/jumpserver.git

安装依赖 RPM 包

(py3) [root@jenkins opt]# yum -y install $(cat /opt/jumpserver/requirements/rpm_requirements.txt)

安装 Python 库依赖

(py3) [root@jenkins opt]# pip install wheel
(py3) [root@jenkins opt]# pip install --upgrade pip setuptools
(py3) [root@jenkins opt]# pip install -r /opt/jumpserver/requirements/requirements.txt

修改 JumpServer 配置文件

(py3) [root@jenkins opt]# cd /opt/jumpserver
(py3) [root@jenkins jumpserver]# cp config_example.yml config.yml
(py3) [root@jenkins jumpserver]# SECRET_KEY=`cat /dev/urandom | tr -dc A-Za-z0-9 | head -c 50` 
(py3) [root@jenkins jumpserver]# echo "SECRET_KEY=$SECRET_KEY" >> ~/.bashrc
(py3) [root@jenkins jumpserver]# BOOTSTRAP_TOKEN=`cat /dev/urandom | tr -dc A-Za-z0-9 | head -c 16`
(py3) [root@jenkins jumpserver]# echo "BOOTSTRAP_TOKEN=$BOOTSTRAP_TOKEN" >> ~/.bashrc
(py3) [root@jenkins jumpserver]# sed -i "s/SECRET_KEY:/SECRET_KEY: $SECRET_KEY/g" /opt/jumpserver/config.yml
(py3) [root@jenkins jumpserver]# sed -i "s/BOOTSTRAP_TOKEN:/BOOTSTRAP_TOKEN: $BOOTSTRAP_TOKEN/g" /opt/jumpserver/config.yml
(py3) [root@jenkins jumpserver]# sed -i "s/# DEBUG: true/DEBUG: false/g" /opt/jumpserver/config.yml
(py3) [root@jenkins jumpserver]# sed -i "s/# LOG_LEVEL: DEBUG/LOG_LEVEL: ERROR/g" /opt/jumpserver/config.yml
(py3) [root@jenkins jumpserver]# sed -i "s/# SESSION_EXPIRE_AT_BROWSER_CLOSE: false/SESSION_EXPIRE_AT_BROWSER_CLOSE: true/g" /opt/jumpserver/config.yml
(py3) [root@jenkins jumpserver]# sed -i "s/DB_PASSWORD: /DB_PASSWORD: $DB_PASSWORD/g" /opt/jumpserver/config.yml
(py3) [root@jenkins jumpserver]# echo -e "\033[31m 你的SECRET_KEY是 $SECRET_KEY \033[0m"
 你的SECRET_KEY是 Yg7Qo43HfjuFRi8MrtZyGAtvs3Ea7V2ZTQgmUvSqaqB5XBfM5T 
(py3) [root@jenkins jumpserver]# echo -e "\033[31m 你的BOOTSTRAP_TOKEN是 $BOOTSTRAP_TOKEN \033[0m"
 你的BOOTSTRAP_TOKEN是 Pc9WvO9eM0o01UD1

确认内容有没有错误

(py3) [root@jenkins jumpserver]# vim config.yml

运行 JumpServer

(py3) [root@jenkins jumpserver]# ./jms start -d
(py3) [root@jenkins jumpserver]# wget -O /usr/lib/systemd/system/jms.service https://demo.jumpserver.org/download/shell/centos/jms.service
(py3) [root@jenkins jumpserver]# chmod 755 /usr/lib/systemd/system/jms.service
(py3) [root@jenkins jumpserver]# systemctl enable jms
Created symlink from /etc/systemd/system/multi-user.target.wants/jms.service to /usr/lib/systemd/system/jms.service.

安装 docker 部署 koko 与 guacamole

(py3) [root@jenkins jumpserver]# yum install -y yum-utils device-mapper-persistent-data lvm2
(py3) [root@jenkins jumpserver]# yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
(py3) [root@jenkins jumpserver]# yum makecache fast
(py3) [root@jenkins jumpserver]# rpm --import https://mirrors.aliyun.com/docker-ce/linux/centos/gpg
(py3) [root@jenkins jumpserver]# yum -y install docker-ce
(py3) [root@jenkins jumpserver]# systemctl enable docker
(py3) [root@jenkins jumpserver]# mkdir /etc/docker
(py3) [root@jenkins jumpserver]# wget -O /etc/docker/daemon.json http://demo.jumpserver.org/download/docker/daemon.json
(py3) [root@jenkins jumpserver]# systemctl restart docker
(py3) [root@jenkins jumpserver]# firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="172.17.0.0/16" port protocol="tcp" port="8080" accept"
success
(py3) [root@jenkins jumpserver]# firewall-cmd --reload
success
(py3) [root@jenkins jumpserver]# Server_IP=`ip addr | grep 'state UP' -A2 | grep inet | egrep -v '(127.0.0.1|inet6|docker)' | awk '{print $2}' | tr -d "addr:" | head -n 1 | cut -d / -f1`
(py3) [root@jenkins jumpserver]#  echo -e "\033[31m 你的服务器IP是 $Server_IP \033[0m"
 你的服务器IP是 172.16.6.124 
(py3) [root@jenkins jumpserver]# docker run --name jms_koko -d -p 2222:2222 -p 127.0.0.1:5000:5000 -e CORE_HOST=http://$Server_IP:8080 -e BOOTSTRAP_TOKEN=$BOOTSTRAP_TOKEN -e LOG_LEVEL=ERROR --restart=always jumpserver/jms_koko:1.5.8
(py3) [root@jenkins jumpserver]# docker run --name jms_guacamole -d -p 127.0.0.1:8081:8080 -e JUMPSERVER_SERVER=http://$Server_IP:8080 -e BOOTSTRAP_TOKEN=$BOOTSTRAP_TOKEN -e GUACAMOLE_LOG_LEVEL=ERROR --restart=always jumpserver/jms_guacamole:1.5.8

安装 Web Terminal 前端: Luna 需要 Nginx 来运行访问 访问(https://github.com/jumpserver/luna/releases)下载对应版本的 release 包, 直接解压, 不需要编译

(py3) [root@jenkins jumpserver]# cd /opt
(py3) [root@jenkins opt]# wget https://demo.jumpserver.org/download/luna/1.5.8/luna.tar.gz
(py3) [root@jenkins opt]# tar xf luna.tar.gz
(py3) [root@jenkins opt]# chown -R root:root luna
(py3) [root@jenkins opt]# rm -rf /etc/nginx/conf.d/default.conf
(py3) [root@jenkins opt]# vi /etc/nginx/conf.d/jumpserver.conf
server {
    listen 80;
    # server_name _;

    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_pass http://localhost:8070;
        proxy_http_version 1.1;
        proxy_buffering off;
        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 / {
        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;
        access_log off;
    }
}

运行 Nginx

(py3) [root@jenkins opt]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
(py3) [root@jenkins opt]# systemctl start nginx

访问

http://172.16.6.124/

CentOS7安装jumpserver

默认账号: admin 密码: admin 到会话管理-终端管理 接受 koko Guacamole 等应用的注册

测试连接

如果是用在 Windows 下, Xshell Terminal 登录语法如下

CentOS7安装jumpserver

CentOS7安装jumpserver

继续阅读
  • 我的QQ
  • QQ扫一扫
  • weinxin
  • 我的头条
  • 头条扫一扫
  • weinxin
IT
  • 本文由 发表于 2020年4月17日16:29:13
  • 除非特殊声明,本站文章均为原创,转载请务必保留本文链接
JumpServer堡垒机v2.0 jumpserver

JumpServer堡垒机v2.0

使用官方的极速模式安装 全新安装的 Centos7 (7.x) 需要连接 互联网 使用 root 用户执行 一键全自动,省去了很多手动安装的烦恼。 一键安装 JumpServer # curl -sS...
JumpServer堡垒机v2.0 jumpserver

JumpServer堡垒机v2.0

使用官方的极速模式安装 全新安装的 Centos7 (7.x) 需要连接 互联网 使用 root 用户执行 一键全自动,省去了很多手动安装的烦恼。 一键安装 JumpServer # curl -sS...