一. 準備 Python3 和 Python 虛擬環境
1.1 安裝依賴包html
yum -y install wget sqlite-devel xz gcc automake zlib-devel openssl-devel epel-release git vim前端
1.2 編譯安裝java
wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tar.xzpython
tar xvf Python-3.6.1.tar.xz && cd Python-3.6.1mysql
./configure && make && make installlinux
1.3 創建 Python 虛擬環境nginx
mkdir /softwaregit
cd /softwaregithub
python3 -m venv py3web
source /software/py3/bin/activate
看到下面的提示符表明成功,之後運行 Jumpserver 都要先運行以上 source 命令,如下全部命令均在該虛擬環境中運行
(py3) [root@ywx542847 software]
如圖 所示:
退出虛擬環境:deactivate
1.4 自動載入 Python 虛擬環境配置
此項僅爲懶癌晚期的人員使用,防止運行 Jumpserver 時忘記載入 Python 虛擬環境致使程序沒法運行。使用autoenv
cd /software
git clone https://github.com/kennethreitz/autoenv.git
echo 'source /software/autoenv/activate.sh' >> ~/.bashrc
source ~/.bashrc
(若是失敗,能夠去bashrc看一下目錄地址是否正確,不正確能夠手動修改一下)
配合jumpserver的.env環境
二. 安裝 Jumpserver
cd /software
git clone https://github.com/jumpserver/jumpserver.git && cd jumpserver && git checkout master
echo "source /software/py3/bin/activate" > /software/jumpserver/.env
cd /software/jumpserver/requirements/
在虛擬環境中安裝依賴包
yum -y install $(cat rpm_requirements.txt)
2.1安裝 Python 庫依賴
pip install -r requirements.txt -i https://pypi.python.org/simple
2.2 安裝 Redis, Jumpserver 使用 Redis 作 cache 和 celery broke
yum -y install redis
systemctl enable redis
systemctl start redis
2.3 安裝 MySQL
yum -y install mariadb mariadb-devel mariadb-server
systemctl enable mariadb
systemctl start mariadb
2.4 建立數據庫 Jumpserver 並受權
$ mysql
> create database jumpserver default charset 'utf8';
> grant all on jumpserver.* to 'jumpserver'@'127.0.0.1' identified by 'weakPassword';
> flush privileges;
2.5 修改 Jumpserver 配置文件
cd /software/jumpserver
cp config_example.py config.py
vim config.py
注意: 配置文件是 Python 格式,不要用 TAB,而要用空格
2.6 生成數據庫表結構和初始化數據
cd /software/jumpserver/utils
bash make_migrations.sh
2.7 運行 Jumpserver
cd /software/jumpserver
./jms start all # 後臺運行使用 -d 參數./jms start all -d
# 新版本更新了運行腳本,使用方式./jms start|stop|status|restart all 後臺運行請添加 -d 參數
三. 安裝 SSH Server 和 WebSocket Server: Coco
3.1 下載或 Clone 項目
cd /software
source /software/py3/bin/activate
git clone https://github.com/jumpserver/coco.git && cd coco && git checkout master
echo "source /software/py3/bin/activate" > /software/coco/.env
首次進入 coco 文件夾會有提示,按 y 便可
# Are you sure you want to allow this? (y/N) y
3.2 安裝依賴
cd /software/coco/requirements
yum -y install $(cat rpm_requirements.txt)
pip install -r requirements.txt -i https://pypi.python.org/simple
3.3 修改配置文件並運行
cd /software/coco
cp conf_example.py conf.py
vim conf.py
注意: 配置文件是 Python 格式,不要用 TAB,而要用空格
./cocod start # 後臺運行使用 -d 參數./cocod start -d
# 新版本更新了運行腳本,使用方式./cocod start|stop|status|restart 後臺運行請添加 -d 參數
四. 安裝 Web Terminal 前端: Luna
4.1 解壓 Luna
cd /software
wget https://github.com/jumpserver/luna/releases/download/1.4.1/luna.tar.gz
tar xvf luna.tar.gz
chown -R root:root luna
五. 安裝 Windows 支持組件(若是不須要管理 windows 資產,能夠直接跳過這一步)
$ rpm --import http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro
$ rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm
$ yum -y localinstall --nogpgcheck https://download1.rpmfusion.org/free/el/rpmfusion-free-release-7.noarch.rpm https://download1.rpmfusion.org/nonfree/el/rpmfusion-nonfree-release-7.noarch.rpm
$ yum install -y java-1.8.0-openjdk libtool
$ yum install -y cairo-devel libjpeg-turbo-devel libpng-devel uuid-devel
$ yum install -y ffmpeg-devel freerdp-devel pango-devel libssh2-devel libtelnet-devel libvncserver-devel pulseaudio-libs-devel openssl-devel libvorbis-devel libwebp-devel ghostscript
$ mkdir /usr/local/lib/freerdp/
$ ln -s /usr/local/lib/freerdp /usr/lib64/freerdp
5.2 編譯安裝 guacamole 服務
cd /software
cd /software/docker-guacamole/
tar -zxvf guacamole-server-0.9.14.tar.gz
autoreconf -fi
./configure --with-init-dir=/etc/init.d
make && make install
cd ..
rm -rf guacamole-server-0.9.14
ldconfig
mkdir -p /software/config/guacamole /software/config/guacamole/lib /software/config/guacamole/extensions # 建立 guacamole 目錄
$ cp /software/docker-guacamole/guacamole-auth-jumpserver-0.9.14.jar /config/guacamole/extensions/guacamole-auth-jumpserver-0.9.14.jar
$ cp /software/docker-guacamole/root/app/guacamole/guacamole.properties /config/guacamole/ # guacamole 配置文件
$ cd /software/config
$ wget http://mirror.bit.edu.cn/apache/tomcat/tomcat-8/v8.5.35/bin/apache-tomcat-8.5.35.tar.gz
$ tar xf apache-tomcat-8.5.35.tar.gz
$ rm -rf apache-tomcat-8.5.35.tar.gz
$ mv apache-tomcat-8.5.35 tomcat8
$ rm -rf /config/tomcat8/webapps/*
$ cp /software/docker-guacamole/guacamole-0.9.14.war /software/config/tomcat8/webapps/ROOT.war # guacamole client
$ sed -i 's/Connector port="8080"/Connector port="8081"/g' `grep 'Connector port="8080"' -rl /software/config/tomcat8/conf/server.xml` # 修改默認端口爲 8081
$ sed -i 's/FINE/WARNING/g' `grep 'FINE' -rl /software/config/tomcat8/conf/logging.properties` # 修改 log 等級爲 WARNING
$ cd /software/config
$ wget https://github.com/ibuler/ssh-forward/releases/download/v0.0.5/linux-amd64.tar.gz
$ tar xf linux-amd64.tar.gz -C /bin/
$ chmod +x /bin/ssh-forward
5.4 配置環境變量
$ export JUMPSERVER_SERVER=http://127.0.0.1:8080 # http://127.0.0.1:8080 指 jumpserver 訪問地址
$ echo "export JUMPSERVER_SERVER=http://127.0.0.1:8080" >> ~/.bashrc
$ export JUMPSERVER_KEY_DIR=/software/config/guacamole/keys
$ echo "export JUMPSERVER_KEY_DIR=/software/config/guacamole/keys" >> ~/.bashrc
$ export GUACAMOLE_HOME=/software/config/guacamole
$ echo "export GUACAMOLE_HOME=/software/config/guacamole" >> ~/.bashrc
5.5 啓動 Guacamole
$ /etc/init.d/guacd start
$ sh /software/config/tomcat8/bin/startup.sh
六. 配置 Nginx 整合各組件
$ yum -y install nginx
$ vi /etc/nginx/nginx.conf
... 原內容include /etc/nginx/conf.d/*.conf;
# 註釋掉整個server {}# 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 / {
# }
# error_page 404 /404.html;
# location = /40x.html {
# }
# error_page 500 502 503 504 /50x.html;
# location = /50x.html {
# }# }... 原內容
6.2 準備配置文件 修改 /etc/nginx/conf.d/jumpserver.conf
$ vi /etc/nginx/conf.d/jumpserver.conf# 注意註釋 nginx.conf 裏面的 server {} 內容 ,CentOS 6 須要修改文件 /etc/nginx/cond.f/default.conf
server {
listen 80; # 代理端口,之後將經過此端口進行訪問,再也不經過8080端口
server_name demo.jumpserver.org; # 修改爲你的域名
client_max_body_size 100m; # 錄像及文件上傳大小限制
location /luna/ {
try_files $uri / /index.html;
alias /software/luna/; # luna 路徑,若是修改安裝目錄,此處須要修改
}
location /media/ {
add_header Content-Encoding gzip;
root /software/jumpserver/data/; # 錄像位置,若是修改安裝目錄,此處須要修改
}
location /static/ {
root /software/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 /coco/ {
proxy_pass http://localhost:5000/coco/; # 若是coco安裝在別的服務器,請填寫它的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;
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;
}
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;
}}
6.3 運行 Nginx
nginx -t # 確保配置沒有問題, 有問題請先解決
# CentOS 7
$ systemctl start nginx
$ systemctl enable nginx
# CentOS 6
$ service nginx start
$ chkconfig nginx on
6.4 開始使用 Jumpserver
檢查應用是否已經正常運行
服務所有啓動後,訪問http://49.4.81.172:8888,訪問nginx代理的端口,不要再經過8080端口訪問
默認帳號: admin 密碼: admin
若是部署過程當中沒有接受應用的註冊,須要到Jumpserver 會話管理-終端管理 接受 Coco Guacamole 等應用的註冊。
測試鏈接
若是登陸客戶端是 macOS 或 Linux ,登陸語法以下
$ ssh -p2222 admin@49.4.81.172
$ sftp -P2222 admin@49.4.81.172
密碼: admin
若是登陸客戶端是 Windows ,Xshell Terminal 登陸語法以下
$ ssh admin@49.4.81.172 2222
$ sftp admin@49.4.81.172 2222
密碼: admin
若是能登錄表明部署成功
# sftp默認上傳的位置在資產的 /tmp 目錄下# windows拖拽上傳的位置在資產的 Guacamole RDP上的 G 目錄下