博客
关于我
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/

你可能感兴趣的文章
NSUserdefault读书笔记
查看>>
NS图绘制工具推荐
查看>>
NT AUTHORITY\NETWORK SERVICE 权限问题
查看>>
NT symbols are incorrect, please fix symbols
查看>>
ntelliJ IDEA 报错:找不到包或者找不到符号
查看>>
ntko web firefox跨浏览器插件_深度比较:2019年6个最好的跨浏览器测试工具
查看>>
ntko文件存取错误_苹果推送 macOS 10.15.4:iCloud 云盘文件夹共享终于来了
查看>>
ntpdate 通过外网同步时间
查看>>
NTPD使用/etc/ntp.conf配置时钟同步详解
查看>>
NTP及Chrony时间同步服务设置
查看>>
NTP配置
查看>>
NUC1077 Humble Numbers【数学计算+打表】
查看>>
NuGet Gallery 开源项目快速入门指南
查看>>
NuGet(微软.NET开发平台的软件包管理工具)在VisualStudio中的安装的使用
查看>>
nuget.org 无法加载源 https://api.nuget.org/v3/index.json 的服务索引
查看>>
Nuget~管理自己的包包
查看>>
NuGet学习笔记001---了解使用NuGet给net快速获取引用
查看>>
nullnullHuge Pages
查看>>
NullPointerException Cannot invoke setSkipOutputConversion(boolean) because functionToInvoke is null
查看>>
null可以转换成任意非基本类型(int/short/long/float/boolean/byte/double/char以外)
查看>>