开源跳板机jumpserver安装
简介
Jumpserver 是全球首款完全开源的堡垒机, 使用GNU GPL v2.0 开源协议, 是符合4A 的专业运维审计系统
Jumpserver 使用Python / Django 进行开发, 遵循Web 2.0 规范, 配备了业界领先的Web Terminal 解决方案, 交互界面美观、用户体验好。
Jumpserver 采纳分布式架构, 支持多机房跨区域部署, 中心节点提供API, 各机房部署登录节点, 可横向扩展、无并发访问限制。
Jumpserver 现已支持管理SSH、Telnet、RDP、VNC 协议资产。
github https://github.com/jumpserver/jumpserver
官方安装 http://docs.jumpserver.org/zh/docs/setup_by_centos.html
特点:
完全开源,GPL授权
Python编写,容易再次开发
实现了跳板机基本功能,认证、授权、审计
集成了Ansible,批量命令等
支持WebTerminal
Bootstrap编写,界面美观
自动收集硬件信息
录像回放
命令搜索
实时监控
批量上传下载
环境配置
服务器环境
- CPU: 4核
- 内存: 8G
- 数据库:mysql 5.6
- 系统:centos 7
- 内核:3.10.0-123.el7.x86_64
-
设置防火墙和selinux
-
设置字符集
setenforce 0 sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config # 修改字符集, 否则可能报input/output error的问题, 因为日志里打印了中文 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
[admin@pe-jira ~]$ getenforce
Disabled
[admin@pe-jira ~]$ echo $LANG
zh_CN.UTF-8
[admin@pe-jira ~]$
依赖包
sudo yum -y install wget gcc epel-release git
安装 Python3.6
[admin@pe-jira ~]$ python -V
Python 3.6.0
[admin@pe-jira ~]$
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
建立 Python 虚拟环境
因为 CentOS 7 自带的是Python2, 而Yum 等工具依赖原来的Python, 为了不扰乱原来的环境我们来使用Python 虚拟环境
mkdir /home/admin/jumpserver cd /home/admin/jumpserver python3.6 -m venv py3 source /home/admin/jumpserver/py3/bin/activate # 看到下面的提示符代表成功, 以后运行 Jumpserver 都要先运行以上 source 命令, 以下所有命令均在该虚拟环境中运行(py3)
安装基础服务
下载或 Clone 项目
项目提交较多 git clone 时较大, 你可以选择去Github 项目页面直接下载zip包。
cd /home/admin/jumpserver/
git clone --depth=1 https://github.com/jumpserver/jumpserver.git
(py3) [admin@pe-jira py3]$ cd /home/admin/jumpserver/ (py3) [admin@pe-jira jumpserver]$ git clone --depth=1 https://github.com/jumpserver/jumpserver.git 正克隆到 'jumpserver'... remote: Enumerating objects: 1065, done. remote: Counting objects: 100% (1065/1065), done. remote: Compressing objects: 100% (928/928), done. remote: Total 1065 (delta 182), reused 610 (delta 80), pack-reused 0 接收对象中: 100% (1065/1065), 6.88 MiB | 530.00 KiB/s, done. 处理 delta 中: 100% (182/182), done. (py3) [admin@pe-jira jumpserver]$ (py3) [admin@pe-jira jumpserver]$ ls jumpserver py3 (py3) [admin@pe-jira jumpserver]$ cd jumpserver/ (py3) [admin@pe-jira jumpserver]$ ls apps config_example.yml Dockerfile entrypoint.sh LICENSE README_EN.md requirements tmp build.sh data docs jms logs README.md run_server.py utils
安装依赖 RPM 包
cd /home/admin/jumpserver/jumpserver/requirements/ sudo yum -y install $(cat rpm_requirements.txt)
安装 Python 库依赖
pip install --upgrade pip setuptools pip install -r 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/
安装 Redis
Jumpserver 使用 Redis 做cache 和celery broke
我是编译安装的跳过啦
yum -y install redis
systemctl enable redis
systemctl start redis
安装 MySQL
我是编译安装的跳过啦
yum -y install mariadb mariadb-devel mariadb-server # centos7下安装的是mariadb systemctl enable mariadb systemctl start mariadb
创建数据库 Jumpserver 并授权
mysql> create database jumpserver default charset 'utf8'; grant all on jumpserver.* to 'jumpserver'@'10.6.76.27' identified by 'cGFrhxIA29ClqaTwrwhy5QqY'; flush privileges; Query OK, 1 row affected (0.08 sec) Query OK, 0 rows affected (0.07 sec) Query OK, 0 rows affected (0.01 sec) mysql> [admin@pe-jira redis]$ mysql -ujumpserver -pcGFrhxIA29ClqaTwrwhy5QqY -hpe-db Warning: Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or g. Your MySQL connection id is 149213 Server version: 5.6.27-log Source distribution Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or 'h' for help. Type 'c' to clear the current input statement. mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | jumpserver | +--------------------+ 2 rows in set (0.00 sec) mysql>
修改Jumpserver配置文件
SECRET_KEY=`cat /dev/urandom | tr -dc A-Za-z0-9 | head -c 50` # 生成随机SECRET_KEY echo "SECRET_KEY=$SECRET_KEY" >> ~/.bashrc BOOTSTRAP_TOKEN=`cat /dev/urandom | tr -dc A-Za-z0-9 | head -c 16` # 生成随机BOOTSTRAP_TOKEN echo "BOOTSTRAP_TOKEN=$BOOTSTRAP_TOKEN" >> ~/.bashrc sed -i "s/SECRET_KEY:/SECRET_KEY: $SECRET_KEY/g" /home/admin/jumpserver/jumpserver/config.yml sed -i "s/BOOTSTRAP_TOKEN:/BOOTSTRAP_TOKEN: $BOOTSTRAP_TOKEN/g" /home/admin/jumpserver/jumpserver/config.yml sed -i "s/# DEBUG: true/DEBUG: false/g" /home/admin/jumpserver/jumpserver/config.yml sed -i "s/# LOG_LEVEL: DEBUG/LOG_LEVEL: ERROR/g" /home/admin/jumpserver/jumpserver/config.yml sed -i "s/# SESSION_EXPIRE_AT_BROWSER_CLOSE: false/SESSION_EXPIRE_AT_BROWSER_CLOSE: true/g" /home/admin/jumpserver/jumpserver/config.yml sed -i "s/DB_PASSWORD: /DB_PASSWORD: $DB_PASSWORD/g" /home/admin/jumpserver/jumpserver/config.yml echo -e "