博客
关于我
centos7安装部署jumpserver
阅读量:514 次
发布时间:2019-03-07

本文共 4076 字,大约阅读时间需要 13 分钟。

CentOS 7 下 Jumpserver 应用部署指南

一、系统环境准备

1. 查看系统版本

# cat /etc/redhat-releaseCentOS Linux release 7.5.1804 (Core)# uname -aLinux localhost.localdomain 3.10.0-862.el7.x86_64 #1 SMP Fri Apr 20 16:44:24 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

2. 关闭 SELINUX 和防火墙

# getenforce  # 查看 SELINUX 状态,如果为 Enable,运行 `setenforce 0`Disabled# systemctl stop firewalld.service  # 关闭防火墙

3. 修改字符集

确保系统支持 UTF-8 加码:

# localedef -c -f UTF-8 -i zh_CN zh_CN.UTF-8# export LC_ALL=zh_CN.UTF-8# echo 'LANG="zh_CN.UTF-8"' > /etc/locale.conf

二、准备 Python 3 和虚拟环境

1. 安装依赖包

# yum -y install wgetvim lrzsz xz gcc git epel-release python-pip python-devel mysql-devel automake autoconf sqlite-devel zlib-devel openssl-devel sshpass readline-devel

2. 编译安装 Python 3

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

3. 创建 Python 虚拟环境

# cd /opt# python3.6 -m venv py3# source /opt/py3/bin/activate  # 成功后提示符显示 `(py3)` 表示虚拟环境已激活

所有以 (py3) 表示的命令均在虚拟环境中运行。

三、安装 Jumpserver

1. 克隆或下载项目

# git clone --depth=1 https://github.com/jumpserver/jumpserver.git

2. 安装依赖包

# cd /opt/jumpserver/requirements# yum -y install $(cat rpm_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/

3. 安装 Python 库依赖

# pip install --upgrade pip setuptools# pip install -r requirements.txt

4. 安装 Redis

# yum -y install redis# systemctl enable redis# systemctl start redis

5. 安装 MySQL(CentOS 7 默认安装 MariaDB)

# yum -y install mariadb mariadb-devel mariadb-server# systemctl enable mariadb# systemctl start mariadb

6. 创建并授权 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;"

7. 修改 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  # 后台运行,带 `-d` 参数

四、安装 SSH 服务器和 WebSocket 服务器(Coco)

1. 克隆项目

# cd /opt# git clone --depth=1 https://github.com/jumpserver/coco.git

2. 安装依赖

# cd /opt/coco/requirements# yum -y install $(cat rpm_requirements.txt)# pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/

3. 修改配置并运行

# cd /opt/coco/# cp config_example.yml config.yml# sed -i "s/BOOTSTRAP_TOKEN: 
/BOOTSTRAP_TOKEN: $BOOTSTRAP_TOKEN/g" /opt/coco/config.yml# sed -i "s/# LOG_LEVEL: INFO/LOG_LEVEL: ERROR/g" /opt/coco/config.yml# ./cocod start -d # 后台运行,带 `-d` 参数

五、安装 Web Terminal 前端(Luna)

1. 下载并解压

# wget https://github.com/jumpserver/luna/releases/download/1.4.10/luna.tar.gz# tar -xvf luna.tar.gz# chown -R root:root luna

六、配置 Nginx 整合各组件

1. 安装 Nginx

# yum install yum-utils# vi /etc/yum.repos.d/nginx.repo# yum makecache fast# yum install -y nginx# rm -rf /etc/nginx/conf.d/default.conf# systemctl enable nginx

2. 修改配置文件

# vim /etc/nginx/conf.d/jumpserver.conf

3. 运行 Nginx

# nginx -t# systemctl start nginx# systemctl enable nginx

七、测试 Jumpserver 功能

1. 访问 web 页面

# curl http://192.168.0.1  # Replace 以实际 IP 地址替换

2. 测试连接

  • Linux/MacOS:
$ ssh -p2222 admin@192.168.0.1密码: admin
  • Windows:
$ ssh admin@192.168.0.1 2222密码: admin

通过以上步骤,Jumpserver 应用在 CentOS 7 环境下已成功部署完毕。

转载地址:http://okmjz.baihongyu.com/

你可能感兴趣的文章
Pandas-从具有嵌套列表列表的现有列创建动态列时出错
查看>>
Pandas-通过对列和索引的值求和来合并两个数据框
查看>>
pandas.columns、get_dummies等用法
查看>>
pandas.DataFrame.copy(deep=True) 实际上并不创建深拷贝
查看>>
pandas.read_csv()的详解-ChatGPT4o作答
查看>>
PANDAS.READ_EXCEL()输出‘;溢出错误:日期值超出范围‘;而不存在日期列
查看>>
pandas100个骚操作:再见 for 循环!速度提升315倍!
查看>>
Pandas:如何根据其他列值的条件对列进行求和?
查看>>
Pandas:对给定列求和 DataFrame 行
查看>>
Pandas、Matplotlib、Pyecharts数据分析实践
查看>>
Pandas中文官档 ~ 基础用法1
查看>>
Pandas中文官档~基础用法2
查看>>
Pandas中文官档~基础用法5
查看>>
Pandas中文官档~基础用法6
查看>>
Pandas中的GROUP BY AND SUM不丢失列
查看>>
Pandas之iloc、loc
查看>>
pandas交换两列
查看>>
pandas介绍-ChatGPT4o作答
查看>>
pandas去除Nan值
查看>>
pandas实战:电商平台用户分析
查看>>