環境:CentOS Linux release 7.5.1804 (Core)
內核:3.10.0-862.el7.x86_64
數據庫:MySQL5.7
詳細參考官方文檔:http://docs.jumpserver.org/zh/docs/step_by_step.html
第一步:關閉firewalld 和 selinux ,修改字符集
# setenforce 0 # 臨時關閉,重啓後失效
# systemctl stop firewalld.service # 臨時關閉,重啓後失效
# 修改字符集,否則可能報 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
第二步: 準備 Python3 和 Python 虛擬環境
2.1 安裝依賴包
# yum -y install wget sqlite-devel xz gcc automake zlib-devel openssl-devel epel-release git
2.2 編譯安裝
# 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
3.3 建立 Python 虛擬環境
# cd /opt
# python3 -m venv py3
# source /opt/py3/bin/activate
3.4 出現下面的樣子,代表成功,以後的操作都在這個下面操作,別忘source /opt/py3/bin/activate
(py3) [root@localhost py3]
第三步:安裝 Jumpserver(別忘source /opt/py3/bin/activate)
3.1 下載或 Clone 項目
# 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 虛擬環境
3.2 安裝依賴 RPM 包
# cd /opt/jumpserver/requirements
# yum -y install $(cat rpm_requirements.txt) # 如果沒有任何報錯請繼續
3.3 安裝 Python 庫依賴
# pip install -r requirements.txt
pip可以指定源(指定不指定,隨意)
mkdir ~/.pip
touch ~/.pip/pip.conf
添加 [global]
trusted-host=mirrors.aliyun.com
index-url=http://mirrors.aliyun.com/pypi/simple/
3.4 安裝 Redis, Jumpserver 使用 Redis 做 cache 和 celery broke
# yum -y install redis
# systemctl enable redis
# systemctl start redis
3.5 安裝 MySQL
# wget http://repo.mysql.com/mysql57-community-release-el7-8.noarch.rpm
# rpm -ivh mysql57-community-release-el7-8.noarch.rpm
# yum install mysql-server -y
# systemctl start mysqld
# systemctl enable mysqld
3.6 創建數據庫 Jumpserver 並授權
$ mysql -uroot -p
> create database jumpserver default charset 'utf8';
> grant all on jumpserver.* to 'jumpserver'@'127.0.0.1' identified by 'weakPassword';
> flush privileges;
3.7 修改 Jumpserver 配置文件
# cd /opt/jumpserver
# cp config_example.py config.py
# vim config.py (把這幾行的配置文件去掉,密碼也換成授權的數據庫密碼)
# MySQL or postgres setting like:
DB_ENGINE = os.environ.get("DB_ENGINE") or 'mysql'
DB_HOST = os.environ.get("DB_HOST") or '127.0.0.1'
DB_PORT = os.environ.get("DB_PORT") or 3306
DB_USER = os.environ.get("DB_USER") or 'jumpserver'
DB_PASSWORD = os.environ.get("DB_PASSWORD") or 'tiger123'
DB_NAME = os.environ.get("DB_NAME") or 'jumpserver'
HTTP_BIND_HOST = '這裏改爲自己的本機IP'
3.8 生成數據庫表結構和初始化數據
# cd /opt/jumpserver/utils
# bash make_migrations.sh
3.9 運行 Jumpserver
# cd /opt/jumpserver
# ./jms start all # 後臺運行使用 -d 參數./jms start all -d
運行不報錯,請瀏覽器訪問 http://IP:8080/ 默認賬號: admin 密碼: admin 頁面顯示不正常先不用處理,繼續往下操作,後面搭建 nginx 代理後即可正常訪問,原因是因爲 django 無法在非 debug 模式下加載靜態資源
四. 安裝 SSH Server 和 WebSocket Server: Coco
4.1 下載或 Clone 項目
新開一個終端,別忘了 source /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 虛擬環境
4.2 安裝依賴
# cd /opt/coco/requirements
# yum -y install $(cat rpm_requirements.txt)
# pip install -r requirements.txt
4.3 修改配置文件並運行
# cd /opt/coco
# mkdir keys
# cp conf_example.py conf.py # 如果 coco 與 jumpserver 分開部署,請手動修改 conf.py
# vim conf.py //這裏我只是改動了一處,把這行的註釋解開,修改爲自己的本機IP
CORE_HOST = os.environ.get("CORE_HOST") or 'http://coco安裝的本機IP:8080'
4.4 啓動coco
# ./cocod start # 後臺運行使用 -d 參數./cocod start -d
啓動成功後去Jumpserver 會話管理-終端管理(http://coco本機IP:8080/terminal/terminal/)接受coco的註冊
五. 安裝 Web Terminal 前端: Luna
Luna 已改爲純前端,需要 Nginx 來運行訪問。
訪問(https://github.com/jumpserver/luna/releases)下載對應版本的 release 包,直接解壓,不需要編譯
5.1 解壓 Luna
# cd /opt
# wget https://github.com/jumpserver/luna/releases/download/1.4.3/luna.tar.gz
# tar xvf luna.tar.gz
# chown -R root:root luna
六. 安裝 Windows 支持組件(如果不需要管理 windows 資產,可以直接跳過這一步)
6.1 Docker安裝 (僅針對CentOS7,CentOS6安裝Docker相對比較複雜)
# yum remove docker-latest-logrotate docker-logrotate docker-selinux dockdocker-engine
# yum install -y yum-utils device-mapper-persistent-data lvm2
# 添加docker官方源
# yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
# yum makecache fast
# yum install docker-ce
# systemctl start docker
# systemctl status docker
6.2 啓動 Guacamole
這裏所需要注意的是 guacamole 暴露出來的端口是 8081,若與主機上其他端口衝突請自定義
# 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://<填寫jumpserver的url地址,也就是自己的IP+8080端口> \
jumpserver/guacamole:latest
啓動成功後去Jumpserver 會話管理-終端管理(http://IP:8080/terminal/terminal/)接受[Gua]開頭的一個註冊
七. 配置 Nginx 整合各組件
7.1 安裝 Nginx 根據喜好選擇安裝方式和版本
# yum -y install nginx
7.2 準備配置文件 修改 /etc/nginx/nginx.conf
# vim /etc/nginx/nginx.conf
# 注意註釋 nginx.conf 裏面的 server {} 內容 ,CentOS 6 需要修改文件 /etc/nginx/cond.f/default.conf
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
root /usr/share/nginx/html;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location /luna/ {
try_files $uri / /index.html;
alias /opt/luna/;
}
location /media/ {
add_header Content-Encoding gzip;
root /opt/jumpserver/data/;
}
location /static/ {
root /opt/jumpserver/data/;
}
location /socket.io/ {
proxy_pass http://192.168.3.211:5000/socket.io/;
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 /coco/ {
proxy_pass http://192.168.3.211:5000/coco/;
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://192.168.3.211:8081/;
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;
}
location / {
proxy_pass http://192.168.3.211:8080;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
7.3 運行 Nginx
nginx -t # 確保配置沒有問題, 有問題請先解決
# CentOS 7
# systemctl start nginx
# systemctl enable nginx
7.4 開始使用 Jumpserver
# cd /opt/jumpserver
# ./jms status # 確定jumpserver已經運行,如果沒有運行請重新啓動jumpserver
# cd /opt/coco
# ./cocod status # 確定jumpserver已經運行,如果沒有運行請重新啓動coco
# 如果安裝了 Guacamole
# docker ps # 檢查容器是否已經正常運行,如果沒有運行請重新啓動Guacamole
服務全部啓動後,訪問 http://IP(不帶端口),訪問nginx代理的端口,不要再通過8080端口訪問
默認賬號: admin 密碼: admin
如果部署過程中沒有接受應用的註冊,需要到Jumpserver 會話管理-終端管理 接受 Coco Guacamole 等應用的註冊。
###測試連接
如果登錄客戶端是 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 目錄下
如果遇到guacamole終端沒了,重啓docker也無效的情況下
rm /opt/guacamole/key/*
重啓docker容器
修改最下面圖標
vim /opt/jumpserver/apps/templates/_footer.html