ubuntu18.04 部署 jumpserver 并设置开机自启动

本文是根据文档 https://jumpserver.readthedocs.io/zh/master/setup_by_ubuntu.html 来安装的,以下都是我在安装过程中出现的问题,希望能给后面安装的小伙伴提供帮助。

一. 准备 Python3 和 Python 虚拟环境

按步骤执行到 " 1.3 建立Python虚拟环境 " 时,' python3.6 -m venv py3 ' 会报错, 需要安装 python3-venv:" apt-get install python3-venv "

 

二. 安装 Jumpserver

执行 " 2.3 安装 Python 库依赖 " 时,' pip install -r requirements.txt ' 执行到第58行可能会有错误,若有错误,可能是缺少依赖 libkrb5-dev:" apt-get install libkrb5-dev "

在 2.6,2.7 中的几个变量的值,可自己设置,但名称相同的值要相等

在 " 2.7 修改 Jumpserver 配置文件 " 中,vi config.yml,其中的 SECRET_KEY 与 BOOTSTRAP_TOKEN 的值都要填上自己刚设置的

 

三. 安装 SSH Server 和 WebSocket Server: Coco

3.3 查看配置文件并运行,vim config.yml 中,BOOTSTRAP_TOKEN 的值改为 jumpserver 设置中一样的

 

四. 安装 Web Terminal 前端: Luna

按安装文档执行

 

五. 安装 Windows 支持组件

" 5.1 安装依赖 " 中,依赖包 ' libpng12-dev ' 会报错,改为 ' libpng-dev '

" 5.2 编译安装 guacamole 服务 ",执行到 ' make && make install ' 时,会报错:在/opt/docker-guacamole/guacamole-server-0.9.14/src/terminal/terminal/typescript.h 中的第100行,' ] ' 前加上 '+8 '

接下来,' ln -s /usr/local/lib/freerdp/*.so /usr/lib/x86_64-linux-gnu/freerdp/ ' 会出错,需先建freerdp文件夹

 

六. 配置 Nginx 整合各组件

按安装文档执行

 

七.设置开机自启动jumpserver

自启动脚本

sudo vi /lib/systemd/system/jms.service

[Unit]
Description=jms
After=network.target mysql.service redis-server.service
Wants=mysql.service redis-server.service

[Service]
Type=forking
Environment="PATH=/opt/py3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin"
ExecStart=/opt/jumpserver/jms start all -d
ExecReload=
ExecStop=/opt/jumpserver/jms stop

[Install]
WantedBy=multi-user.target

sudo chmod +x /lib/systemd/system/jms.service

sudo systemctl enable jms

 

sudo vi /lib/systemd/system/coco.service

[Unit]
Description=coco
After=network.target jms.service

[Service]
Type=forking
PIDFile=/opt/coco/coco.pid
Environment="PATH=/opt/py3/bin"
ExecStart=/opt/coco/cocod start -d
ExecReload=
ExecStop=/opt/coco/cocod stop

[Install]
WantedBy=multi-user.target

sudo chmod +x /lib/systemd/system/coco.service

sudo systemctl enable coco

 

sudo vi /lib/systemd/system/guacamole.service

[Unit]
Description=guacamole
After=network.target jms.service
Wants=jms.service

[Service]
Type=forking
#PIDFile=/etc/init.d
#BOOTSTRAP_TOKEN=******
Environment="JUMPSERVER_SERVER=http://127.0.0.1:8080" "JUMPSERVER_KEY_DIR=/config/guacamole/keys" "GUACAMOLE_HOME=/config/guacamole" "BOOTSTRAP_TOKEN=******"
ExecStart=/etc/init.d/guacd start 
ExecReload=
ExecStop=/etc/init.d/guacd stop

[Install]
WantedBy=multi-user.target

sudo chmod +x /lib/systemd/system/guacamole.service

sudo systemctl enable guacamole

 

sudo vi /lib/systemd/system/tomcat.service

[Unit]
Description=tomcat
After=network.target jms.service
Wants=jms.service

[Service]
Type=forking
#PIDFile=/config/tomcat8/tomcat.pid
#BOOTSTRAP_TOKEN=******
Environment="JUMPSERVER_SERVER=http://127.0.0.1:8080" "JUMPSERVER_KEY_DIR=/config/guacamole/keys" "GUACAMOLE_HOME=/config/guacamole" "BOOTSTRAP_TOKEN=******"
ExecStart=/config/tomcat8/bin/startup.sh
ExecReload=
ExecStop=/config/tomcat8/bin/shutdown.sh

[Install]
WantedBy=multi-user.target

sudo chmod +x /lib/systemd/system/tomcat.service

sudo systemctl enable tomcat

 

sudo vi /etc/systemd/system/rc-local.service

[Unit] 
Description=/etc/rc.local Compatibility 
ConditionPathExists=/etc/rc.local 
[Service] 
Type=forking 
ExecStart=/etc/rc.local start 
TimeoutSec=0 
StandardOutput=tty 
RemainAfterExit=yes 
SysVStartPriority=99 
[Install] 
WantedBy=multi-user.target

sudo vi /etc/rc.local

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
sudo systemctl start jms.service
sudo systemctl start coco.service
sudo systemctl start guacamole.service
sudo systemctl stop tomcat.service
echo "看到这行字,说明添加自启动脚本成功。" > /usr/local/test.log
exit 0

sudo chmod +x /etc/rc.local

sudo systemctl enable rc-local

sudo reboot

你可能感兴趣的:(ubuntu18.04 部署 jumpserver 并设置开机自启动)