标签:间隔 pytho alias heartbeat https 认证 one 组件 section
# cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core)
# uname -r
3.10.0-693.21.1.el7.x86_64
# systemctl stop firewalld.service
# sed -i ‘/^SELINUX/s/enforcing/disabled/g‘ /etc/selinux/config
# grep -i ^selinux /etc/selinux/config
SELINUX=disabled
SELINUXTYPE=targeted
# 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
# yum -y install wget sqlite-devel xz gcc automake zlib-devel openssl-devel epel-release git
# wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tar.xz
# tar xvf Python-3.6.1.tar.xz && cd Python-3.6.1
# ./configure && make && make install
# cd /opt
# python3 -m venv py3
# source /opt/py3/bin/activate
看到下面的提示符代表成功,以后运行 Jumpserver 都要先运行以上 source 命令,以下所有命令均在该虚拟环境中运行
(py3) [root@localhost py3]
# cd /opt
# git clone git://github.com/kennethreitz/autoenv.git
# echo ‘source /opt/autoenv/activate.sh‘ >> ~/.bashrc
# source ~/.bashrc
# cd /opt/
# git clone https://github.com/jumpserver/jumpserver.git && cd jumpserver && git checkout master
# echo "source /opt/py3/bin/activate" > /opt/jumpserver/.env # 进入 jumpserver 目录时将自动载入 python 虚拟环境
# cd /opt/jumpserver/requirements
# yum -y install $(cat rpm_requirements.txt) # 如果没有任何报错请继续
# pip install -r requirements.txt -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
以上仅为临时使用,如果想配置成默认的源,方法如下:
需要创建或修改配置文件(一般都是创建)
Linux 在 ~/.pip/pip.conf/
修改内容为:
[global]
index-url = http://pypi.douban.com/simple
[install]
trusted-host=pypi.douban.com
# yum -y install redis
# systemctl enable redis
# systemctl start redis
# yum -y install mariadb mariadb-devel mariadb-server
# systemctl enable mariadb
# systemctl start mariadb
# mysql_secure_installation #设置root登录密码,然后一路回车
# mysql -uroot -p123456
> create database jumpserver default charset ‘utf8‘;
> grant all on jumpserver.* to ‘jumpserver‘@‘127.0.0.1‘ identified by ‘123456‘;
> flush privileges;
# cd /opt/jumpserver
# cp config_example.py config.py
# vim config.py
注意:配置文件是Python格式,不要用TAB,而要用空格
"""
jumpserver.config
~~~~~~~~~~~~~~~~~
Jumpserver project setting file
:copyright: (c) 2014-2017 by Jumpserver Team
:license: GPL v2, see LICENSE for more details.
"""
import os
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
class Config:
# Use it to encrypt or decrypt data
# Jumpserver 使用 SECRET_KEY 进行加密,请务必修改以下设置
# SECRET_KEY = os.environ.get(‘SECRET_KEY‘) or ‘2vym+ky!997d5kkcc64mnz06y1mmui3lut#(^wd=%s_qj$1%x‘
SECRET_KEY = ‘2vym+ky!997d5kkcc64mnz06y1mmui3lut#(^wd=%s_qj$1%x‘ ‘请随意输入随机字符串(推荐字符大于等于 50位)‘
# Django security setting, if your disable debug model, you should setting that
ALLOWED_HOSTS = [‘*‘]
# DEBUG 模式 True为开启 False为关闭,默认开启,生产环境推荐关闭
# 注意:如果设置了DEBUG = False,访问8080端口页面会显示不正常,需要搭建 nginx 代理才可以正常访问
DEBUG = False
# 日志级别,默认为DEBUG,可调整为INFO, WARNING, ERROR, CRITICAL,默认INFO
LOG_LEVEL = ‘WARNING‘
LOG_DIR = os.path.join(BASE_DIR, ‘logs‘)
# 使用的数据库配置,支持sqlite3, mysql, postgres等,默认使用sqlite3
# See https://docs.djangoproject.com/en/1.10/ref/settings/#databases
# 默认使用SQLite3,如果使用其他数据库请注释下面两行
# DB_ENGINE = ‘sqlite3‘
# DB_NAME = os.path.join(BASE_DIR, ‘data‘, ‘db.sqlite3‘)
# 如果需要使用mysql或postgres,请取消下面的注释并输入正确的信息,本例使用mysql做演示(mariadb也是mysql)
DB_ENGINE = ‘mysql‘
DB_HOST = ‘127.0.0.1‘
DB_PORT = 3306
DB_USER = ‘jumpserver‘
DB_PASSWORD = ‘123456‘
DB_NAME = ‘jumpserver‘
# Django 监听的ip和端口,生产环境推荐把0.0.0.0修改成127.0.0.1,这里的意思是允许x.x.x.x访问,127.0.0.1表示仅允许自身访问
# ./manage.py runserver 127.0.0.1:8080
HTTP_BIND_HOST = ‘127.0.0.1‘
HTTP_LISTEN_PORT = 8080
# Redis 相关设置
REDIS_HOST = ‘127.0.0.1‘
REDIS_PORT = 6379
REDIS_PASSWORD = ‘‘
REDIS_DB_CELERY = 3
REDIS_DB_CACHE = 4
def __init__(self):
pass
def __getattr__(self, item):
return None
class DevelopmentConfig(Config):
pass
class TestConfig(Config):
pass
class ProductionConfig(Config):
pass
# Default using Config settings, you can write if/else for different env
config = DevelopmentConfig()
# cd /opt/jumpserver/utils
# bash make_migrations.sh
# cd /opt/jumpserver
# ./jms start all # 后台运行使用 -d 参数./jms start all -d
运行不报错,浏览器访问http://IP地址:8080 默认账号:admin 密码:admin
souce /opt/py3/bin/activate
# cd /opt
# source /opt/py3/bin/activate
# git clone https://github.com/jumpserver/coco.git && cd coco && git checkout master
# echo "source /opt/py3/bin/activate" > /opt/coco/.env # 进入 coco 目录时将自动载入 python 虚拟环境
# cd /opt/coco/requirements
# yum -y install $(cat rpm_requirements.txt)
# pip install -r requirements.txt
# cd /opt/coco
# cp conf_example.py conf.py # 如果 coco 与 jumpserver 分开部署,请手动修改 conf.py
# vim conf.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
import os
BASE_DIR = os.path.dirname(__file__)
class Config:
"""
Coco config file, coco also load config from server update setting below
"""
# 项目名称, 会用来向Jumpserver注册, 识别而已, 不能重复
# NAME = "localhost"
NAME = "coco"
# Jumpserver项目的url, api请求注册会使用, 如果Jumpserver没有运行在127.0.0.1:8080,请修改此处
# CORE_HOST = os.environ.get("CORE_HOST") or ‘http://127.0.0.1:8080‘
CORE_HOST = ‘http://127.0.0.1:8080‘
# 启动时绑定的ip, 默认 0.0.0.0
# BIND_HOST = ‘0.0.0.0‘
# 监听的SSH端口号, 默认2222
# SSHD_PORT = 2222
# 监听的HTTP/WS端口号,默认5000
# HTTPD_PORT = 5000
# 项目使用的ACCESS KEY, 默认会注册,并保存到 ACCESS_KEY_STORE中,
# 如果有需求, 可以写到配置文件中, 格式 access_key_id:access_key_secret
# ACCESS_KEY = None
# ACCESS KEY 保存的地址, 默认注册后会保存到该文件中
# ACCESS_KEY_STORE = os.path.join(BASE_DIR, ‘keys‘, ‘.access_key‘)
# 加密密钥
# SECRET_KEY = None
# 设置日志级别 [‘DEBUG‘, ‘INFO‘, ‘WARN‘, ‘ERROR‘, ‘FATAL‘, ‘CRITICAL‘]
# LOG_LEVEL = ‘INFO‘
LOG_LEVEL = ‘WARN‘
# 日志存放的目录
# LOG_DIR = os.path.join(BASE_DIR, ‘logs‘)
# Session录像存放目录
# SESSION_DIR = os.path.join(BASE_DIR, ‘sessions‘)
# 资产显示排序方式, [‘ip‘, ‘hostname‘]
# ASSET_LIST_SORT_BY = ‘ip‘
# 登录是否支持密码认证
# PASSWORD_AUTH = True
# 登录是否支持秘钥认证
# PUBLIC_KEY_AUTH = True
# 和Jumpserver 保持心跳时间间隔
# HEARTBEAT_INTERVAL = 5
# Admin的名字,出问题会提示给用户
# ADMINS = ‘‘
COMMAND_STORAGE = {
"TYPE": "server"
}
REPLAY_STORAGE = {
"TYPE": "server"
}
config = Config()
# ./cocod start # 后台运行使用 -d 参数./cocod start -d
启动成功后去Jumpserver 会话管理-终端管理(http://IP地址:8080/terminal/terminal/) 接受coco的注册。
Luna已改为纯前端,需要Nginx来运行访问
# cd /opt
# wget https://github.com/jumpserver/luna/releases/download/1.3.3/luna.tar.gz
# tar xvf luna.tar.gz
# chown -R root:root luna
因为手动安装 guacamole 组件比较复杂,这里提供打包好的 docker 使用, 启动 guacamole
# yum remove docker-latest-logrotate docker-logrotate docker-selinux dockdocker-engine
# yum install -y yum-utils device-mapper-persistent-data lvm2
# yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
# rpm --import http://mirrors.aliyun.com/docker-ce/linux/centos/gpg
# yum makecache fast
# yum -y install docker-ce
# systemctl start docker
# systemctl status docker
这里所需要注意的是 guacamole 暴露出来的端口是 8081,若与主机上其他端口冲突请自定义
启动成功后去Jumpserver 会话管理-终端管理(http://IP地址:8080/terminal/terminal/) 接受[Gua]开头的一个注册
# docker run --name jms_guacamole -d -p 8081:8080 -v /opt/guacamole/key:/config/guacamole/key -e JUMPSERVER_KEY_DIR=/config/guacamole/key -e JUMPSERVER_SERVER=http://IP地址 jumpserver/guacamole:latest
# yum -y install nginx
# vim /etc/nginx/nginx.conf
... 省略
# 把默认server配置块改成这样,原有的内容请保持不动
server {
listen 80; # 代理端口,以后将通过此端口进行访问,不再通过8080端口
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 /socket.io/ {
proxy_pass http://localhost:5000/socket.io/; # 如果coco安装在别的服务器,请填写它的ip
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/; # 如果guacamole安装在别的服务器,请填写它的ip
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;
client_max_body_size 100m; # Windows 文件上传大小限制
}
location / {
proxy_pass http://localhost:8080; # 如果jumpserver安装在别的服务器,请填写它的ip
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
# systemctl enable nginx
# cd /opt/jumpserver
# ./jms status # 确定jumpserver已经运行,如果没有运行请重新启动jumpserver
# cd /opt/coco
# ./cocod status # 确定jumpserver已经运行,如果没有运行请重新启动coco
# 如果安装了 Guacamole
# docker ps # 检查容器是否已经正常运行,如果没有运行请重新启动Guacamole
服务全部启动后,访问http://ip,访问Nginx代理的端口,不要再通过8080端口访问。
如果部署过程中,没有接受应用的注册,需要到Jumpserver的会话管理-终端管理 接受Coco Guacamode等应用的注册。
测试连接
如果登录客户端是 macOS 或 Linux ,登录语法如下
$ ssh -p2222 admin@IP
$ sftp -P2222 admin@IP
密码: admin
如果登录客户端是 Windows ,Xshell Terminal 登录语法如下
$ ssh admin@IP 2222
$ sftp admin@IP 2222
密码: admin
如果能登陆代表部署成功
# sftp默认上传的位置在资产的 /tmp 目录下
# windows拖拽上传的位置在资产的 Guacamole RDP上的 G 目录下
标签:间隔 pytho alias heartbeat https 认证 one 组件 section
原文地址:https://www.cnblogs.com/shawhe/p/11294402.html