一哈 發表於 2019-5-9 18:26:00

CentOS安装部署jumperserver(堡垒机)

<div id="id5" class="section">
<h2>可以参考官方的文档:http://docs.jumpserver.org/zh/docs/introduce.html</h2>
<h2>测试环境</h2>
<ul class="simple">
<li>系统: CentOS 7</li>
<li>IP: 192.168.244.144</li>
<li>设置 selinux 和防火墙</li>
</ul>
<div class="highlight-shell notranslate">
<div class="highlight">
<div class="cnblogs_code">
<pre>$ firewall-cmd --zone=public --add-port=<span style="color: rgba(128, 0, 128, 1)">80</span>/tcp --<span style="color: rgba(0, 0, 0, 1)">permanent# nginx 端口
$ firewall</span>-cmd --zone=public --add-port=<span style="color: rgba(128, 0, 128, 1)">2222</span>/tcp --<span style="color: rgba(0, 0, 0, 1)">permanent# 用户SSH登录端口 coco

$ firewall</span>-cmd --<span style="color: rgba(0, 0, 0, 1)">reload# 重新载入规则

$ setenforce </span><span style="color: rgba(128, 0, 128, 1)">0</span><span style="color: rgba(0, 0, 0, 1)">
$ </span><span style="color: rgba(0, 0, 255, 1)">sed</span> -i <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">s/SELINUX=enforcing/SELINUX=disabled/g</span><span style="color: rgba(128, 0, 0, 1)">"</span> /etc/selinux/<span style="color: rgba(0, 0, 0, 1)">config

# 修改字符集, 否则可能报 input</span>/<span style="color: rgba(0, 0, 0, 1)">output error的问题, 因为日志里打印了中文
$ localedef </span>-c -f UTF-<span style="color: rgba(128, 0, 128, 1)">8</span> -i zh_CN zh_CN.UTF-<span style="color: rgba(128, 0, 128, 1)">8</span><span style="color: rgba(0, 0, 0, 1)">
$ export LC_ALL</span>=zh_CN.UTF-<span style="color: rgba(128, 0, 128, 1)">8</span><span style="color: rgba(0, 0, 0, 1)">
$ </span><span style="color: rgba(0, 0, 255, 1)">echo</span> <span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">LANG="zh_CN.UTF-8"</span><span style="color: rgba(128, 0, 0, 1)">'</span> &gt; /etc/locale.conf</pre>
</div>
<p>&nbsp;</p>
</div>
</div>
</div>
<div id="python3-python" class="section">
<h2>一. 准备 Python3 和 Python 虚拟环境</h2>
<p><strong>1.1 安装依赖包</strong></p>
<div class="highlight-shell notranslate">
<div class="highlight">
<div class="cnblogs_code">
<pre>$ <span style="color: rgba(0, 0, 255, 1)">yum</span> -y <span style="color: rgba(0, 0, 255, 1)">install</span> <span style="color: rgba(0, 0, 255, 1)">wget</span> <span style="color: rgba(0, 0, 255, 1)">gcc</span> epel-release git</pre>
</div>
<p>&nbsp;</p>
</div>
</div>
<p><strong>1.2 安装 Python3.6</strong></p>
<div class="highlight-default notranslate">
<div class="highlight">
<div class="cnblogs_code">
<pre>$ <span style="color: rgba(0, 0, 255, 1)">yum</span> -y <span style="color: rgba(0, 0, 255, 1)">install</span> python36 python36-<span style="color: rgba(0, 0, 0, 1)">devel

# 如果下载速度很慢, 可以换国内源
$ </span><span style="color: rgba(0, 0, 255, 1)">wget</span> -O /etc/<span style="color: rgba(0, 0, 255, 1)">yum</span>.repos.d/epel.repo http:<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">mirrors.aliyun.com/repo/epel-7.repo</span>
$ <span style="color: rgba(0, 0, 255, 1)">yum</span> -y <span style="color: rgba(0, 0, 255, 1)">install</span> python36 python36-devel</pre>
</div>
<p>&nbsp;</p>
</div>
</div>
<p><strong>1.3 建立 Python 虚拟环境</strong></p>
<p>因为 CentOS 7 自带的是 Python2, 而 Yum 等工具依赖原来的 Python, 为了不扰乱原来的环境我们来使用 Python 虚拟环境</p>
<div class="highlight-shell notranslate">
<div class="highlight">
<div class="cnblogs_code">
<pre>$ cd /<span style="color: rgba(0, 0, 0, 1)">opt
$ python3.</span><span style="color: rgba(128, 0, 128, 1)">6</span> -<span style="color: rgba(0, 0, 0, 1)">m venv py3
$ source </span>/opt/py3/bin/<span style="color: rgba(0, 0, 0, 1)">activate

# 看到下面的提示符代表成功, 以后运行 Jumpserver 都要先运行以上 source 命令, 以下所有命令均在该虚拟环境中运行
(py3) </span></pre>
</div>
<p>&nbsp;</p>
</div>
</div>
</div>
<div id="jumpserver" class="section">
<h2>二. 安装 Jumpserver</h2>
<p><strong>2.1 下载或 Clone 项目</strong></p>
<p>项目提交较多 git clone 时较大, 你可以选择去 Github 项目页面直接下载zip包。</p>
<div class="highlight-shell notranslate">
<div class="highlight">
<div class="cnblogs_code">
<pre>$ cd /opt/<span style="color: rgba(0, 0, 0, 1)">
$ git clone </span>--depth=<span style="color: rgba(128, 0, 128, 1)">1</span> https:<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">github.com/jumpserver/jumpserver.git</span></pre>
</div>
<p>&nbsp;</p>
</div>
</div>
<p><strong>2.2 安装依赖 RPM 包</strong></p>
<div class="highlight-shell notranslate">
<div class="highlight">
<div class="cnblogs_code">
<pre>$ cd /opt/jumpserver/<span style="color: rgba(0, 0, 0, 1)">requirements
$ </span><span style="color: rgba(0, 0, 255, 1)">yum</span> -y <span style="color: rgba(0, 0, 255, 1)">install</span> $(<span style="color: rgba(0, 0, 255, 1)">cat</span> rpm_requirements.txt)# 如果没有任何报错请继续</pre>
</div>
<p>&nbsp;</p>
</div>
</div>
<p><strong>2.3 安装 Python 库依赖</strong></p>
<div class="highlight-shell notranslate">
<div class="highlight">
<div class="cnblogs_code">
<pre>$ pip <span style="color: rgba(0, 0, 255, 1)">install</span> --<span style="color: rgba(0, 0, 0, 1)">upgrade pip setuptools
$ pip </span><span style="color: rgba(0, 0, 255, 1)">install</span> -<span style="color: rgba(0, 0, 0, 1)">r requirements.txt

# 如果下载速度很慢, 可以换国内源
$ pip </span><span style="color: rgba(0, 0, 255, 1)">install</span> --upgrade pip setuptools -i https:<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">mirrors.aliyun.com/pypi/simple/</span>
$ pip <span style="color: rgba(0, 0, 255, 1)">install</span> -r requirements.txt -i https:<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">mirrors.aliyun.com/pypi/simple/</span></pre>
</div>
<p>&nbsp;</p>
</div>
</div>
<p><strong>2.4 安装 Redis, Jumpserver 使用 Redis 做 cache 和 celery broke</strong></p>
<div class="highlight-shell notranslate">
<div class="highlight">
<div class="cnblogs_code">
<pre>$ <span style="color: rgba(0, 0, 255, 1)">yum</span> -y <span style="color: rgba(0, 0, 255, 1)">install</span><span style="color: rgba(0, 0, 0, 1)"> redis
$ systemctl enable redis
$ systemctl start redis</span></pre>
</div>
<p>&nbsp;</p>
</div>
</div>
<p><strong>2.5 安装 MySQL</strong></p>
<p>本教程使用 Mysql 作为数据库, 如果不使用 Mysql 可以跳过相关 Mysql 安装和配置</p>
<div class="highlight-shell notranslate">
<div class="highlight">
<div class="cnblogs_code">
<pre>$ <span style="color: rgba(0, 0, 255, 1)">yum</span> -y <span style="color: rgba(0, 0, 255, 1)">install</span> mariadb mariadb-devel mariadb-<span style="color: rgba(0, 0, 0, 1)">server # centos7下安装的是mariadb
$ systemctl enable mariadb
$ systemctl start mariadb</span></pre>
</div>
<p>&nbsp;</p>
</div>
</div>
<p><strong>2.6 创建数据库 Jumpserver 并授权</strong></p>
<div class="highlight-shell notranslate">
<div class="highlight">
<div class="cnblogs_code">
<pre>$ DB_PASSWORD=`<span style="color: rgba(0, 0, 255, 1)">cat</span> /dev/urandom | <span style="color: rgba(0, 0, 255, 1)">tr</span> -dc A-Za-z0-<span style="color: rgba(128, 0, 128, 1)">9</span> | <span style="color: rgba(0, 0, 255, 1)">head</span> -c <span style="color: rgba(128, 0, 128, 1)">24</span><span style="color: rgba(0, 0, 0, 1)">`# 生成随机数据库密码
$ </span><span style="color: rgba(0, 0, 255, 1)">echo</span> -e <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">\033[31m 你的数据库密码是 $DB_PASSWORD \033[0m</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">
$ mysql </span>-uroot -e <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">create database jumpserver default charset 'utf8'; grant all on jumpserver.* to 'jumpserver'@'127.0.0.1' identified by '$DB_PASSWORD'; flush privileges;</span><span style="color: rgba(128, 0, 0, 1)">"</span></pre>
</div>
<p>&nbsp;</p>
</div>
</div>
<p><strong>2.7 修改 Jumpserver 配置文件</strong></p>
<div class="highlight-shell notranslate">
<div class="highlight">
<div class="cnblogs_code">
<pre>$ cd /opt/<span style="color: rgba(0, 0, 0, 1)">jumpserver
$ </span><span style="color: rgba(0, 0, 255, 1)">cp</span><span style="color: rgba(0, 0, 0, 1)"> config_example.yml config.yml

$ SECRET_KEY</span>=`<span style="color: rgba(0, 0, 255, 1)">cat</span> /dev/urandom | <span style="color: rgba(0, 0, 255, 1)">tr</span> -dc A-Za-z0-<span style="color: rgba(128, 0, 128, 1)">9</span> | <span style="color: rgba(0, 0, 255, 1)">head</span> -c <span style="color: rgba(128, 0, 128, 1)">50</span><span style="color: rgba(0, 0, 0, 1)">`# 生成随机SECRET_KEY
$ </span><span style="color: rgba(0, 0, 255, 1)">echo</span> <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">SECRET_KEY=$SECRET_KEY</span><span style="color: rgba(128, 0, 0, 1)">"</span> &gt;&gt; ~/<span style="color: rgba(0, 0, 0, 1)">.bashrc
$ BOOTSTRAP_TOKEN</span>=`<span style="color: rgba(0, 0, 255, 1)">cat</span> /dev/urandom | <span style="color: rgba(0, 0, 255, 1)">tr</span> -dc A-Za-z0-<span style="color: rgba(128, 0, 128, 1)">9</span> | <span style="color: rgba(0, 0, 255, 1)">head</span> -c <span style="color: rgba(128, 0, 128, 1)">16</span><span style="color: rgba(0, 0, 0, 1)">`# 生成随机BOOTSTRAP_TOKEN
$ </span><span style="color: rgba(0, 0, 255, 1)">echo</span> <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">BOOTSTRAP_TOKEN=$BOOTSTRAP_TOKEN</span><span style="color: rgba(128, 0, 0, 1)">"</span> &gt;&gt; ~/<span style="color: rgba(0, 0, 0, 1)">.bashrc

$ </span><span style="color: rgba(0, 0, 255, 1)">sed</span> -i <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">s/SECRET_KEY:/SECRET_KEY: $SECRET_KEY/g</span><span style="color: rgba(128, 0, 0, 1)">"</span> /opt/jumpserver/<span style="color: rgba(0, 0, 0, 1)">config.yml
$ </span><span style="color: rgba(0, 0, 255, 1)">sed</span> -i <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">s/BOOTSTRAP_TOKEN:/BOOTSTRAP_TOKEN: $BOOTSTRAP_TOKEN/g</span><span style="color: rgba(128, 0, 0, 1)">"</span> /opt/jumpserver/<span style="color: rgba(0, 0, 0, 1)">config.yml
$ </span><span style="color: rgba(0, 0, 255, 1)">sed</span> -i <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">s/# DEBUG: true/DEBUG: false/g</span><span style="color: rgba(128, 0, 0, 1)">"</span> /opt/jumpserver/<span style="color: rgba(0, 0, 0, 1)">config.yml
$ </span><span style="color: rgba(0, 0, 255, 1)">sed</span> -i <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">s/# LOG_LEVEL: DEBUG/LOG_LEVEL: ERROR/g</span><span style="color: rgba(128, 0, 0, 1)">"</span> /opt/jumpserver/<span style="color: rgba(0, 0, 0, 1)">config.yml
$ </span><span style="color: rgba(0, 0, 255, 1)">sed</span> -i <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">s/# SESSION_EXPIRE_AT_BROWSER_CLOSE: false/SESSION_EXPIRE_AT_BROWSER_CLOSE: true/g</span><span style="color: rgba(128, 0, 0, 1)">"</span> /opt/jumpserver/<span style="color: rgba(0, 0, 0, 1)">config.yml
$ </span><span style="color: rgba(0, 0, 255, 1)">sed</span> -i <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">s/DB_PASSWORD: /DB_PASSWORD: $DB_PASSWORD/g</span><span style="color: rgba(128, 0, 0, 1)">"</span> /opt/jumpserver/<span style="color: rgba(0, 0, 0, 1)">config.yml

$ </span><span style="color: rgba(0, 0, 255, 1)">echo</span> -e <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">\033[31m 你的SECRET_KEY是 $SECRET_KEY \033[0m</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">
$ </span><span style="color: rgba(0, 0, 255, 1)">echo</span> -e <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">\033[31m 你的BOOTSTRAP_TOKEN是 $BOOTSTRAP_TOKEN \033[0m</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">

$ </span><span style="color: rgba(0, 0, 255, 1)">vi</span><span style="color: rgba(0, 0, 0, 1)"> config.yml# 确认内容有没有错误
# SECURITY WARNING: keep the secret key used </span><span style="color: rgba(0, 0, 255, 1)">in</span> production secret!<span style="color: rgba(0, 0, 0, 1)">
# 加密秘钥 生产环境中请修改为随机字符串, 请勿外泄
SECRET_KEY:

# SECURITY WARNING: keep the bootstrap token used </span><span style="color: rgba(0, 0, 255, 1)">in</span> production secret!<span style="color: rgba(0, 0, 0, 1)">
# 预共享Token coco和guacamole用来注册服务账号, 不在使用原来的注册接受机制
BOOTSTRAP_TOKEN:

# Development </span><span style="color: rgba(0, 0, 255, 1)">env</span><span style="color: rgba(0, 0, 0, 1)"> open this, when error occur display the full process track, Production disable it
# DEBUG 模式 开启DEBUG后遇到错误时可以看到更多日志
DEBUG: </span><span style="color: rgba(0, 0, 255, 1)">false</span><span style="color: rgba(0, 0, 0, 1)">

# DEBUG, INFO, WARNING, ERROR, CRITICAL can set. See https:</span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">docs.djangoproject.com/en/1.10/topics/logging/</span>
<span style="color: rgba(0, 0, 0, 1)"># 日志级别
LOG_LEVEL: ERROR
# LOG_DIR:

# Session expiration setting, Default </span><span style="color: rgba(128, 0, 128, 1)">24</span><span style="color: rgba(0, 0, 0, 1)"> hour, Also set expired on on browser close
# 浏览器Session过期时间, 默认24小时, 也可以设置浏览器关闭则过期
# SESSION_COOKIE_AGE: </span><span style="color: rgba(128, 0, 128, 1)">86400</span><span style="color: rgba(0, 0, 0, 1)">
SESSION_EXPIRE_AT_BROWSER_CLOSE: </span><span style="color: rgba(0, 0, 255, 1)">true</span><span style="color: rgba(0, 0, 0, 1)">

# Database setting, Support sqlite3, mysql, postgres ....
# 数据库设置
# See https:</span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">docs.djangoproject.com/en/1.10/ref/settings/#databases</span>
<span style="color: rgba(0, 0, 0, 1)">
# SQLite setting:
# 使用单文件sqlite数据库
# DB_ENGINE: sqlite3
# DB_NAME:

# MySQL or postgres setting like:
# 使用Mysql作为数据库
DB_ENGINE: mysql
DB_HOST: </span><span style="color: rgba(128, 0, 128, 1)">127.0</span>.<span style="color: rgba(128, 0, 128, 1)">0.1</span><span style="color: rgba(0, 0, 0, 1)">
DB_PORT: </span><span style="color: rgba(128, 0, 128, 1)">3306</span><span style="color: rgba(0, 0, 0, 1)">
DB_USER: jumpserver
DB_PASSWORD:
DB_NAME: jumpserver

# When Django start it will bind this host and port
# .</span>/manage.py runserver <span style="color: rgba(128, 0, 128, 1)">127.0</span>.<span style="color: rgba(128, 0, 128, 1)">0.1</span>:<span style="color: rgba(128, 0, 128, 1)">8080</span><span style="color: rgba(0, 0, 0, 1)">
# 运行时绑定端口
HTTP_BIND_HOST: </span><span style="color: rgba(128, 0, 128, 1)">0.0</span>.<span style="color: rgba(128, 0, 128, 1)">0.0</span><span style="color: rgba(0, 0, 0, 1)">
HTTP_LISTEN_PORT: </span><span style="color: rgba(128, 0, 128, 1)">8080</span><span style="color: rgba(0, 0, 0, 1)">

# Use Redis as broker </span><span style="color: rgba(0, 0, 255, 1)">for</span><span style="color: rgba(0, 0, 0, 1)"> celery and web socket
# Redis配置
REDIS_HOST: </span><span style="color: rgba(128, 0, 128, 1)">127.0</span>.<span style="color: rgba(128, 0, 128, 1)">0.1</span><span style="color: rgba(0, 0, 0, 1)">
REDIS_PORT: </span><span style="color: rgba(128, 0, 128, 1)">6379</span><span style="color: rgba(0, 0, 0, 1)">
# REDIS_PASSWORD:
# REDIS_DB_CELERY: </span><span style="color: rgba(128, 0, 128, 1)">3</span><span style="color: rgba(0, 0, 0, 1)">
# REDIS_DB_CACHE: </span><span style="color: rgba(128, 0, 128, 1)">4</span><span style="color: rgba(0, 0, 0, 1)">

# Use OpenID authorization
# 使用OpenID 来进行认证设置
# BASE_SITE_URL: http:</span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">localhost:8080</span>
# AUTH_OPENID: <span style="color: rgba(0, 0, 255, 1)">false</span><span style="color: rgba(0, 0, 0, 1)"># True or False
# AUTH_OPENID_SERVER_URL: https:</span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">openid-auth-server.com/</span>
# AUTH_OPENID_REALM_NAME: realm-<span style="color: rgba(0, 0, 0, 1)">name
# AUTH_OPENID_CLIENT_ID: client</span>-<span style="color: rgba(0, 0, 255, 1)">id</span><span style="color: rgba(0, 0, 0, 1)">
# AUTH_OPENID_CLIENT_SECRET: client</span>-<span style="color: rgba(0, 0, 0, 1)">secret

# OTP settings
# OTP</span>/<span style="color: rgba(0, 0, 0, 1)">MFA 配置
# OTP_VALID_WINDOW: </span><span style="color: rgba(128, 0, 128, 1)">0</span><span style="color: rgba(0, 0, 0, 1)">
# OTP_ISSUER_NAME: Jumpserver</span></pre>
</div>
<p>&nbsp;</p>
</div>
</div>
<p><strong>2.8 运行 Jumpserver</strong></p>
<div class="highlight-shell notranslate">
<div class="highlight">
<div class="cnblogs_code">
<pre>$ cd /opt/<span style="color: rgba(0, 0, 0, 1)">jumpserver
$ .</span>/jms start all -d# 后台运行使用 -d 参数./jms start all -<span style="color: rgba(0, 0, 0, 1)">d

# 新版本更新了运行脚本, 使用方式.</span>/jms start|stop|status all后台运行请添加 -d 参数</pre>
</div>
<p>&nbsp;</p>
</div>
</div>
<p>运行不报错, 请继续往下操作</p>
</div>
<div id="ssh-server-websocket-server-coco" class="section">
<h2>三. 安装 SSH Server 和 WebSocket Server: Coco</h2>
<p><strong>3.1 下载或 Clone 项目</strong></p>
<div class="highlight-shell notranslate">
<div class="highlight">
<div class="cnblogs_code">
<pre>$ cd /<span style="color: rgba(0, 0, 0, 1)">opt
$ source </span>/opt/py3/bin/<span style="color: rgba(0, 0, 0, 1)">activate
$ git clone </span>--depth=<span style="color: rgba(128, 0, 128, 1)">1</span> https:<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">github.com/jumpserver/coco.git</span></pre>
</div>
<p>&nbsp;</p>
</div>
</div>
<p><strong>3.2 安装依赖</strong></p>
<div class="highlight-shell notranslate">
<div class="highlight">
<div class="cnblogs_code">
<pre>$ cd /opt/coco/<span style="color: rgba(0, 0, 0, 1)">requirements
$ </span><span style="color: rgba(0, 0, 255, 1)">yum</span> -y <span style="color: rgba(0, 0, 255, 1)">install</span> $(<span style="color: rgba(0, 0, 255, 1)">cat</span><span style="color: rgba(0, 0, 0, 1)"> rpm_requirements.txt)
$ pip </span><span style="color: rgba(0, 0, 255, 1)">install</span> -<span style="color: rgba(0, 0, 0, 1)">r requirements.txt

# 如果下载速度很慢, 可以换国内源
$ pip </span><span style="color: rgba(0, 0, 255, 1)">install</span> -r requirements.txt -i https:<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">mirrors.aliyun.com/pypi/simple/</span></pre>
</div>
<p>&nbsp;</p>
</div>
</div>
<p><strong>3.3 修改配置文件并运行</strong></p>
<div class="highlight-shell notranslate">
<div class="highlight">
<div class="cnblogs_code">
<pre>$ cd /opt/<span style="color: rgba(0, 0, 0, 1)">coco
$ </span><span style="color: rgba(0, 0, 255, 1)">cp</span><span style="color: rgba(0, 0, 0, 1)"> config_example.yml config.yml

$ </span><span style="color: rgba(0, 0, 255, 1)">sed</span> -i <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">s/BOOTSTRAP_TOKEN: &lt;PleasgeChangeSameWithJumpserver&gt;/BOOTSTRAP_TOKEN: $BOOTSTRAP_TOKEN/g</span><span style="color: rgba(128, 0, 0, 1)">"</span> /opt/coco/<span style="color: rgba(0, 0, 0, 1)">config.yml
$ </span><span style="color: rgba(0, 0, 255, 1)">sed</span> -i <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">s/# LOG_LEVEL: INFO/LOG_LEVEL: ERROR/g</span><span style="color: rgba(128, 0, 0, 1)">"</span> /opt/coco/<span style="color: rgba(0, 0, 0, 1)">config.yml

$ </span><span style="color: rgba(0, 0, 255, 1)">vi</span><span style="color: rgba(0, 0, 0, 1)"> config.yml
# 项目名称, 会用来向Jumpserver注册, 识别而已, 不能重复
# NAME: {{ Hostname }}

# Jumpserver项目的url, api请求注册会使用
CORE_HOST: http:</span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">127.0.0.1:8080</span>
<span style="color: rgba(0, 0, 0, 1)">
# Bootstrap Token, 预共享秘钥, 用来注册coco使用的service account和terminal
# 请和jumpserver 配置文件中保持一致, 注册完成后可以删除
BOOTSTRAP_TOKEN: </span>&lt;PleasgeChangeSameWithJumpserver&gt;<span style="color: rgba(0, 0, 0, 1)">

# 启动时绑定的ip, 默认 </span><span style="color: rgba(128, 0, 128, 1)">0.0</span>.<span style="color: rgba(128, 0, 128, 1)">0.0</span><span style="color: rgba(0, 0, 0, 1)">
# BIND_HOST: </span><span style="color: rgba(128, 0, 128, 1)">0.0</span>.<span style="color: rgba(128, 0, 128, 1)">0.0</span><span style="color: rgba(0, 0, 0, 1)">

# 监听的SSH端口号, 默认2222
# SSHD_PORT: </span><span style="color: rgba(128, 0, 128, 1)">2222</span><span style="color: rgba(0, 0, 0, 1)">

# 监听的HTTP</span>/<span style="color: rgba(0, 0, 0, 1)">WS端口号, 默认5000
# HTTPD_PORT: </span><span style="color: rgba(128, 0, 128, 1)">5000</span><span style="color: rgba(0, 0, 0, 1)">

# 项目使用的ACCESS KEY, 默认会注册, 并保存到 ACCESS_KEY_STORE中,
# 如果有需求, 可以写到配置文件中, 格式 access_key_id:access_key_secret
# ACCESS_KEY: </span><span style="color: rgba(0, 0, 255, 1)">null</span><span style="color: rgba(0, 0, 0, 1)">

# ACCESS KEY 保存的地址, 默认注册后会保存到该文件中
# ACCESS_KEY_STORE: data</span>/keys/<span style="color: rgba(0, 0, 0, 1)">.access_key

# 加密密钥
# SECRET_KEY: </span><span style="color: rgba(0, 0, 255, 1)">null</span><span style="color: rgba(0, 0, 0, 1)">

# 设置日志级别
LOG_LEVEL: ERROR

# 日志存放的目录
# LOG_DIR: logs

# SSH白名单
# ALLOW_SSH_USER: all

# SSH黑名单, 如果用户同时在白名单和黑名单, 黑名单优先生效
# BLOCK_SSH_USER:
#   </span>-<span style="color: rgba(0, 0, 0, 1)">

# 和Jumpserver 保持心跳时间间隔
# HEARTBEAT_INTERVAL: </span><span style="color: rgba(128, 0, 128, 1)">5</span><span style="color: rgba(0, 0, 0, 1)">

# Admin的名字, 出问题会提示给用户
# ADMINS: </span><span style="color: rgba(128, 0, 0, 1)">''</span><span style="color: rgba(0, 0, 0, 1)">

# SSH连接超时时间 (default </span><span style="color: rgba(128, 0, 128, 1)">15</span><span style="color: rgba(0, 0, 0, 1)"> seconds)
# SSH_TIMEOUT: </span><span style="color: rgba(128, 0, 128, 1)">15</span><span style="color: rgba(0, 0, 0, 1)">

# 语言
# LANGUAGE_CODE: zh

# SFTP的根目录, 可选 </span>/<span style="color: rgba(0, 0, 0, 1)">tmp, Home其他自定义目录
# SFTP_ROOT: </span>/<span style="color: rgba(0, 0, 0, 1)">tmp

# SFTP是否显示隐藏文件
# SFTP_SHOW_HIDDEN_FILE: </span><span style="color: rgba(0, 0, 255, 1)">false</span><span style="color: rgba(0, 0, 0, 1)">
$ .</span>/cocod start -d# 后台运行使用 -d 参数./cocod start -<span style="color: rgba(0, 0, 0, 1)">d

# 新版本更新了运行脚本, 使用方式.</span>/cocod start|stop|status后台运行请添加 -d 参数</pre>
</div>
<p>&nbsp;</p>
</div>
</div>
</div>
<div id="web-terminal-luna" class="section">
<h2>四. 安装 Web Terminal 前端: Luna</h2>
<p>Luna 已改为纯前端, 需要 Nginx 来运行访问</p>
<p>访问(https://github.com/jumpserver/luna/releases)下载对应版本的 release 包, 直接解压不需要编译</p>
<p><strong>4.1 解压 Luna</strong></p>
<div class="highlight-shell notranslate">
<div class="highlight">
<div class="cnblogs_code">
<pre>$ cd /<span style="color: rgba(0, 0, 0, 1)">opt
$ </span><span style="color: rgba(0, 0, 255, 1)">wget</span> https:<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">github.com/jumpserver/luna/releases/download/1.4.10/luna.tar.gz</span>
<span style="color: rgba(0, 0, 0, 1)">
# 如果网络有问题导致下载无法完成可以使用下面地址
$ </span><span style="color: rgba(0, 0, 255, 1)">wget</span> https:<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">demo.jumpserver.org/download/luna/1.4.10/luna.tar.gz</span>
<span style="color: rgba(0, 0, 0, 1)">
$ </span><span style="color: rgba(0, 0, 255, 1)">tar</span> xf luna.<span style="color: rgba(0, 0, 255, 1)">tar</span><span style="color: rgba(0, 0, 0, 1)">.gz
$ </span><span style="color: rgba(0, 0, 255, 1)">chown</span> -R root:root luna</pre>
</div>
<p>&nbsp;</p>
</div>
</div>
</div>
<div id="windows-windows" class="section">
<h2>五. 安装 Windows 支持组件(如果不需要管理 windows 资产, 可以直接跳过这一步)</h2>
<p><strong>5.1 安装依赖</strong></p>
<div class="highlight-shell notranslate">
<div class="highlight">
<div class="cnblogs_code">
<pre>$ rpm --import http:<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro</span>
$ rpm -Uvh http:<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm</span>
$ <span style="color: rgba(0, 0, 255, 1)">yum</span> -y localinstall --nogpgcheck https:<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">download1.rpmfusion.org/free/el/rpmfusion-free-release-7.noarch.rpm </span><span style="color: rgba(0, 128, 0, 1); text-decoration: underline">https://download1.rpmfusion.org/nonfree/el/rpmfusion-nonfree-release-7.noarch.rpm</span>
<span style="color: rgba(0, 0, 0, 1)">
$ </span><span style="color: rgba(0, 0, 255, 1)">yum</span> <span style="color: rgba(0, 0, 255, 1)">install</span> -y java-<span style="color: rgba(128, 0, 128, 1)">1.8</span>.<span style="color: rgba(128, 0, 128, 1)">0</span>-<span style="color: rgba(0, 0, 0, 1)">openjdk libtool
$ </span><span style="color: rgba(0, 0, 255, 1)">yum</span> <span style="color: rgba(0, 0, 255, 1)">install</span> -y cairo-devel libjpeg-turbo-devel libpng-devel uuid-<span style="color: rgba(0, 0, 0, 1)">devel
$ </span><span style="color: rgba(0, 0, 255, 1)">yum</span> <span style="color: rgba(0, 0, 255, 1)">install</span> -y ffmpeg-devel freerdp-devel freerdp-plugins pango-devel libssh2-devel libtelnet-devel libvncserver-devel pulseaudio-libs-devel openssl-devel libvorbis-devel libwebp-devel ghostscript</pre>
</div>
<p>&nbsp;</p>
</div>
</div>
<p><strong>5.2 编译安装 guacamole 服务</strong></p>
<div class="highlight-shell notranslate">
<div class="highlight">
<div class="cnblogs_code">
<pre>$ cd /<span style="color: rgba(0, 0, 0, 1)">opt
$ git clone </span>--depth=<span style="color: rgba(128, 0, 128, 1)">1</span> https:<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">github.com/jumpserver/docker-guacamole.git</span>
$ cd /opt/docker-guacamole/<span style="color: rgba(0, 0, 0, 1)">
$ </span><span style="color: rgba(0, 0, 255, 1)">tar</span> -xf guacamole-server-<span style="color: rgba(128, 0, 128, 1)">0.9</span>.<span style="color: rgba(128, 0, 128, 1)">14</span>.<span style="color: rgba(0, 0, 255, 1)">tar</span><span style="color: rgba(0, 0, 0, 1)">.gz
$ cd guacamole</span>-server-<span style="color: rgba(128, 0, 128, 1)">0.9</span>.<span style="color: rgba(128, 0, 128, 1)">14</span><span style="color: rgba(0, 0, 0, 1)">
$ autoreconf </span>-<span style="color: rgba(0, 0, 255, 1)">fi</span><span style="color: rgba(0, 0, 0, 1)">
$ .</span>/configure --with-init-<span style="color: rgba(0, 0, 255, 1)">dir</span>=/etc/<span style="color: rgba(0, 0, 0, 1)">init.d
$ </span><span style="color: rgba(0, 0, 255, 1)">make</span> &amp;&amp; <span style="color: rgba(0, 0, 255, 1)">make</span> <span style="color: rgba(0, 0, 255, 1)">install</span><span style="color: rgba(0, 0, 0, 1)">
$ </span><span style="color: rgba(0, 0, 255, 1)">ln</span> -s /usr/local/lib/freerdp<span style="color: rgba(0, 128, 0, 1)">/*</span><span style="color: rgba(0, 128, 0, 1)">.so /usr/lib64/freerdp/
$ cd ..
$ rm -rf guacamole-server-0.9.14
$ ldconfig</span></pre>
</div>
<p>&nbsp;</p>
</div>
</div>
<p><strong>5.3 配置 Tomcat</strong></p>
<div class="highlight-shell notranslate">
<div class="highlight">
<div class="cnblogs_code">
<pre>$ <span style="color: rgba(0, 0, 255, 1)">mkdir</span> -p /config/guacamole /config/guacamole/lib /config/guacamole/<span style="color: rgba(0, 0, 0, 1)">extensions# 创建 guacamole 目录
$ </span><span style="color: rgba(0, 0, 255, 1)">ln</span> -sf /opt/docker-guacamole/guacamole-auth-jumpserver-<span style="color: rgba(128, 0, 128, 1)">0.9</span>.<span style="color: rgba(128, 0, 128, 1)">14</span>.jar /config/guacamole/extensions/guacamole-auth-jumpserver-<span style="color: rgba(128, 0, 128, 1)">0.9</span>.<span style="color: rgba(128, 0, 128, 1)">14</span><span style="color: rgba(0, 0, 0, 1)">.jar
$ </span><span style="color: rgba(0, 0, 255, 1)">ln</span> -sf /opt/docker-guacamole/root/app/guacamole/guacamole.properties /config/guacamole/<span style="color: rgba(0, 0, 0, 1)">guacamole.properties# guacamole 配置文件

$ cd </span>/<span style="color: rgba(0, 0, 0, 1)">config
$ </span><span style="color: rgba(0, 0, 255, 1)">wget</span> http:<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-8/v8.5.40/bin/apache-tomcat-8.5.40.tar.gz</span>
$ <span style="color: rgba(0, 0, 255, 1)">tar</span> xf apache-tomcat-<span style="color: rgba(128, 0, 128, 1)">8.5</span>.<span style="color: rgba(128, 0, 128, 1)">40</span>.<span style="color: rgba(0, 0, 255, 1)">tar</span><span style="color: rgba(0, 0, 0, 1)">.gz
$ </span><span style="color: rgba(0, 0, 255, 1)">rm</span> -rf apache-tomcat-<span style="color: rgba(128, 0, 128, 1)">8.5</span>.<span style="color: rgba(128, 0, 128, 1)">40</span>.<span style="color: rgba(0, 0, 255, 1)">tar</span><span style="color: rgba(0, 0, 0, 1)">.gz
$ </span><span style="color: rgba(0, 0, 255, 1)">mv</span> apache-tomcat-<span style="color: rgba(128, 0, 128, 1)">8.5</span>.<span style="color: rgba(128, 0, 128, 1)">40</span><span style="color: rgba(0, 0, 0, 1)"> tomcat8
$ </span><span style="color: rgba(0, 0, 255, 1)">rm</span> -rf /config/tomcat8/webapps<span style="color: rgba(0, 128, 0, 1)">/*</span><span style="color: rgba(0, 128, 0, 1)">
$ ln -sf /opt/docker-guacamole/guacamole-0.9.14.war /config/tomcat8/webapps/ROOT.war# guacamole client
$ sed -i 's/Connector port="8080"/Connector port="8081"/g' /config/tomcat8/conf/server.xml# 修改默认端口为 8081
$ sed -i 's/FINE/WARNING/g' /config/tomcat8/conf/logging.properties# 修改 log 等级为 WARNING

$ cd /config
$ wget </span><span style="color: rgba(0, 128, 0, 1); text-decoration: underline">https://github.com/ibuler/ssh-forward/releases/download/v0.0.5/linux-amd64.tar.gz</span><span style="color: rgba(0, 128, 0, 1)">

# 如果网络有问题导致下载无法完成可以使用下面地址
$ wget </span><span style="color: rgba(0, 128, 0, 1); text-decoration: underline">https://demo.jumpserver.org/download/ssh-forward/v0.0.5/linux-amd64.tar.gz</span><span style="color: rgba(0, 128, 0, 1)">

$ tar xf linux-amd64.tar.gz -C /bin/
$ chmod +x /bin/ssh-forward</span></pre>
</div>
<p>&nbsp;</p>
</div>
</div>
<p><strong>5.4 配置环境变量</strong></p>
<div class="highlight-shell notranslate">
<div class="highlight">
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 0, 1)"># 勿多次执行以下环境设置
$ export JUMPSERVER_SERVER</span>=http:<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">127.0.0.1:8080# </span><span style="color: rgba(0, 128, 0, 1); text-decoration: underline">http://127.0.0.1</span><span style="color: rgba(0, 128, 0, 1)">:8080 指 jumpserver 访问地址</span>
$ <span style="color: rgba(0, 0, 255, 1)">echo</span> <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">export JUMPSERVER_SERVER=http://127.0.0.1:8080</span><span style="color: rgba(128, 0, 0, 1)">"</span> &gt;&gt; ~/<span style="color: rgba(0, 0, 0, 1)">.bashrc

# BOOTSTRAP_TOKEN 为 Jumpserver</span>/<span style="color: rgba(0, 0, 0, 1)">config.yml 里面的 BOOTSTRAP_TOKEN
$ export BOOTSTRAP_TOKEN</span>=<span style="color: rgba(0, 0, 0, 1)">$BOOTSTRAP_TOKEN
$ </span><span style="color: rgba(0, 0, 255, 1)">echo</span> <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">export BOOTSTRAP_TOKEN=$BOOTSTRAP_TOKEN</span><span style="color: rgba(128, 0, 0, 1)">"</span> &gt;&gt; ~/<span style="color: rgba(0, 0, 0, 1)">.bashrc
$ export JUMPSERVER_KEY_DIR</span>=/config/guacamole/<span style="color: rgba(0, 0, 0, 1)">keys
$ </span><span style="color: rgba(0, 0, 255, 1)">echo</span> <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">export JUMPSERVER_KEY_DIR=/config/guacamole/keys</span><span style="color: rgba(128, 0, 0, 1)">"</span> &gt;&gt; ~/<span style="color: rgba(0, 0, 0, 1)">.bashrc
$ export GUACAMOLE_HOME</span>=/config/<span style="color: rgba(0, 0, 0, 1)">guacamole
$ </span><span style="color: rgba(0, 0, 255, 1)">echo</span> <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">export GUACAMOLE_HOME=/config/guacamole</span><span style="color: rgba(128, 0, 0, 1)">"</span> &gt;&gt; ~/.bashrc</pre>
</div>
<p>&nbsp;</p>
</div>
</div>
<p><strong>5.5 启动 Guacamole</strong></p>
<div class="highlight-shell notranslate">
<div class="highlight">
<div class="cnblogs_code">
<pre>$ /etc/init.d/<span style="color: rgba(0, 0, 0, 1)">guacd start
$ </span><span style="color: rgba(0, 0, 255, 1)">sh</span> /config/tomcat8/bin/startup.<span style="color: rgba(0, 0, 255, 1)">sh</span></pre>
</div>
<p>&nbsp;</p>
</div>
</div>
</div>
<div id="nginx" class="section">
<h2>六. 配置 Nginx 整合各组件</h2>
<p><strong>6.1 安装 Nginx</strong></p>
<div class="highlight-shell notranslate">
<div class="highlight">
<div class="cnblogs_code">
<pre>$ <span style="color: rgba(0, 0, 255, 1)">yum</span> <span style="color: rgba(0, 0, 255, 1)">install</span> <span style="color: rgba(0, 0, 255, 1)">yum</span>-<span style="color: rgba(0, 0, 0, 1)">utils
$ </span><span style="color: rgba(0, 0, 255, 1)">vi</span> /etc/<span style="color: rgba(0, 0, 255, 1)">yum</span>.repos.d/<span style="color: rgba(0, 0, 0, 1)">nginx.repo


name</span>=<span style="color: rgba(0, 0, 0, 1)">nginx stable repo
baseurl</span>=http:<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">nginx.org/packages/centos/$releasever/$basearch/</span>
gpgcheck=<span style="color: rgba(128, 0, 128, 1)">1</span><span style="color: rgba(0, 0, 0, 1)">
enabled</span>=<span style="color: rgba(128, 0, 128, 1)">1</span><span style="color: rgba(0, 0, 0, 1)">
gpgkey</span>=https:<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">nginx.org/keys/nginx_signing.key</span>
<span style="color: rgba(0, 0, 0, 1)">
$ </span><span style="color: rgba(0, 0, 255, 1)">yum</span><span style="color: rgba(0, 0, 0, 1)"> makecache fast
$ </span><span style="color: rgba(0, 0, 255, 1)">yum</span> <span style="color: rgba(0, 0, 255, 1)">install</span> -<span style="color: rgba(0, 0, 0, 1)">y nginx
$ </span><span style="color: rgba(0, 0, 255, 1)">rm</span> -rf /etc/nginx/conf.d/<span style="color: rgba(0, 0, 0, 1)">default.conf
$ systemctl enable nginx</span></pre>
</div>
<p>&nbsp;</p>
</div>
</div>
<p><strong>6.3 准备配置文件 修改 /etc/nginx/conf.d/jumpserver.conf</strong></p>
<div class="highlight-nginx notranslate">
<div class="highlight">
<div class="cnblogs_code">
<pre>$ <span style="color: rgba(0, 0, 255, 1)">vi</span> /etc/nginx/conf.d/<span style="color: rgba(0, 0, 0, 1)">jumpserver.conf

server {
    listen </span><span style="color: rgba(128, 0, 128, 1)">80</span><span style="color: rgba(0, 0, 0, 1)">;# 代理端口, 以后将通过此端口进行访问, 不再通过8080端口
    # server_name demo.jumpserver.org;# 修改成你的域名或者注释掉

    client_max_body_size 100m;# 录像及文件上传大小限制

    location </span>/luna/<span style="color: rgba(0, 0, 0, 1)"> {
      try_files $uri </span>/ /<span style="color: rgba(0, 0, 0, 1)">index.html;
      alias </span>/opt/luna/<span style="color: rgba(0, 0, 0, 1)">;# luna 路径, 如果修改安装目录, 此处需要修改
    }

    location </span>/media/<span style="color: rgba(0, 0, 0, 1)"> {
      add_header Content</span>-Encoding <span style="color: rgba(0, 0, 255, 1)">gzip</span><span style="color: rgba(0, 0, 0, 1)">;
      root </span>/opt/jumpserver/data/<span style="color: rgba(0, 0, 0, 1)">;# 录像位置, 如果修改安装目录, 此处需要修改
    }

    location </span>/static/<span style="color: rgba(0, 0, 0, 1)"> {
      root </span>/opt/jumpserver/data/<span style="color: rgba(0, 0, 0, 1)">;# 静态资源, 如果修改安装目录, 此处需要修改
    }

    location </span>/socket.io/<span style="color: rgba(0, 0, 0, 1)"> {
      proxy_pass       http:</span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">localhost:5000/socket.io/;# 如果coco安装在别的服务器, 请填写它的ip</span>
<span style="color: rgba(0, 0, 0, 1)">      proxy_buffering off;
      proxy_http_version </span><span style="color: rgba(128, 0, 128, 1)">1.1</span><span style="color: rgba(0, 0, 0, 1)">;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">upgrade</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">;
      proxy_set_header X</span>-Real-<span style="color: rgba(0, 0, 0, 1)">IP $remote_addr;
      proxy_set_header Host $host;
      proxy_set_header X</span>-Forwarded-<span style="color: rgba(0, 0, 0, 1)">For $proxy_add_x_forwarded_for;
      access_log off;
    }

    location </span>/coco/<span style="color: rgba(0, 0, 0, 1)"> {
      proxy_pass       http:</span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">localhost:5000/coco/;# 如果coco安装在别的服务器, 请填写它的ip</span>
      proxy_set_header X-Real-<span style="color: rgba(0, 0, 0, 1)">IP $remote_addr;
      proxy_set_header Host $host;
      proxy_set_header X</span>-Forwarded-<span style="color: rgba(0, 0, 0, 1)">For $proxy_add_x_forwarded_for;
      access_log off;
    }

    location </span>/guacamole/<span style="color: rgba(0, 0, 0, 1)"> {
      proxy_pass       http:</span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">localhost:8081/;# 如果guacamole安装在别的服务器, 请填写它的ip</span>
<span style="color: rgba(0, 0, 0, 1)">      proxy_buffering off;
      proxy_http_version </span><span style="color: rgba(128, 0, 128, 1)">1.1</span><span style="color: rgba(0, 0, 0, 1)">;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection $http_connection;
      proxy_set_header X</span>-Real-<span style="color: rgba(0, 0, 0, 1)">IP $remote_addr;
      proxy_set_header Host $host;
      proxy_set_header X</span>-Forwarded-<span style="color: rgba(0, 0, 0, 1)">For $proxy_add_x_forwarded_for;
      access_log off;
    }

    location </span>/<span style="color: rgba(0, 0, 0, 1)"> {
      proxy_pass http:</span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">localhost:8080;# 如果jumpserver安装在别的服务器, 请填写它的ip</span>
      proxy_set_header X-Real-<span style="color: rgba(0, 0, 0, 1)">IP $remote_addr;
      proxy_set_header Host $host;
      proxy_set_header X</span>-Forwarded-<span style="color: rgba(0, 0, 0, 1)">For $proxy_add_x_forwarded_for;
    }
}</span></pre>
</div>
<p>&nbsp;</p>
</div>
</div>
<p><strong>6.3 运行 Nginx</strong></p>
<div class="highlight-shell notranslate">
<div class="highlight">
<div class="cnblogs_code">
<pre>nginx -<span style="color: rgba(0, 0, 0, 1)">t   # 确保配置没有问题, 有问题请先解决

# CentOS </span><span style="color: rgba(128, 0, 128, 1)">7</span><span style="color: rgba(0, 0, 0, 1)">
$ systemctl start nginx
$ systemctl enable nginx</span></pre>
</div>
<p>&nbsp;</p>
</div>
</div>
<p><strong>6.4 开始使用 Jumpserver</strong></p>
<p>检查应用是否已经正常运行</p>
<p>服务全部启动后, 访问&nbsp;http://192.168.244.144, 访问nginx代理的端口, 不要再通过8080端口访问</p>
<p>默认账号: admin 密码: admin</p>
<p>到Jumpserver 会话管理-终端管理 检查 Coco Guacamole 等应用的注册。</p>
<p><strong>测试连接</strong></p>
<div class="highlight-shell notranslate">
<div class="highlight">
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 0, 1)">如果登录客户端是 macOS 或 Linux, 登录语法如下
$ </span><span style="color: rgba(0, 0, 255, 1)">ssh</span> -p2222 admin@<span style="color: rgba(128, 0, 128, 1)">192.168</span>.<span style="color: rgba(128, 0, 128, 1)">244.144</span><span style="color: rgba(0, 0, 0, 1)">
$ sftp </span>-P2222 admin@<span style="color: rgba(128, 0, 128, 1)">192.168</span>.<span style="color: rgba(128, 0, 128, 1)">244.144</span><span style="color: rgba(0, 0, 0, 1)">
密码: admin

如果登录客户端是 Windows, Xshell Terminal 登录语法如下
$ </span><span style="color: rgba(0, 0, 255, 1)">ssh</span> admin@<span style="color: rgba(128, 0, 128, 1)">192.168</span>.<span style="color: rgba(128, 0, 128, 1)">244.144</span> <span style="color: rgba(128, 0, 128, 1)">2222</span><span style="color: rgba(0, 0, 0, 1)">
$ sftp admin@</span><span style="color: rgba(128, 0, 128, 1)">192.168</span>.<span style="color: rgba(128, 0, 128, 1)">244.144</span> <span style="color: rgba(128, 0, 128, 1)">2222</span><span style="color: rgba(0, 0, 0, 1)">
密码: admin
如果能登陆代表部署成功

# sftp默认上传的位置在资产的 </span>/<span style="color: rgba(0, 0, 0, 1)">tmp 目录下
# windows拖拽上传的位置在资产的 Guacamole RDP上的 G 目录下</span></pre>
</div>
<p>&nbsp;</p>
</div>
</div>
</div>

</div>
<div id="MySignature" role="contentinfo">
    ----------当你发现自己的才华撑不起野心时,就请安静下来学习吧!----------<br><br>
来源:https://www.cnblogs.com/shawhe/p/10840227.html
頁: [1]
查看完整版本: CentOS安装部署jumperserver(堡垒机)