溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

jumpserver堡壘機(jī)的安裝部署

發(fā)布時(shí)間:2020-05-29 10:49:38 來(lái)源:億速云 閱讀:1395 作者:Leah 欄目:系統(tǒng)運(yùn)維

這篇文章給大家分享的是jumpserver堡壘機(jī)的安裝部署的詳細(xì)介紹,相信大部分人都還沒學(xué)不知道怎樣部署,為了讓大家更加了解,給大家總結(jié)了以下內(nèi)容,話不多說,一起往下看吧。


一、環(huán)境準(zhǔn)備

?   系統(tǒng):CentOS 7
?   IP:192.168.20.3
?   數(shù)據(jù)庫(kù):mariadb
?   反向代理:nginx

注:若是測(cè)試環(huán)境,內(nèi)存最少4G,雙核CPU。
在進(jìn)行下面的操作前,請(qǐng)下載我提供的各個(gè)源碼包。
首先將環(huán)境字體設(shè)置成中文,因?yàn)閖umpserver的日志文件里面的內(nèi)容會(huì)包含中字符,不支持可能會(huì)亂碼。

[root@jumpserver ~]# localedef -c -f UTF-8 -i  zh_CN  zh_CN.UTF-8
[root@jumpserver ~]# export LC_ALL=zh_CN.UTF-8
[root@jumpserver ~]# echo 'LC_ALL=zh_CN.UTF-8' > /etc/locale.conf 

二、配置Python 3環(huán)境

[root@jumpserver ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
[root@jumpserver ~]# yum -y install wget sqlite-devel xz gcc automake zlib-devel openssl-devel epel-release git
[root@jumpserver ~]# tar xf Python-3.6.1.tar.xz -C /usr/src
[root@jumpserver ~]# cd /usr/src/Python-3.6.1/
[root@jumpserver Python-3.6.1]# ./configure && make && make install
[root@jumpserver Python-3.6.1]# cd /opt
[root@jumpserver opt]# python3 -m venv py3
[root@jumpserver opt]# source /opt/py3/bin/activate   
#設(shè)置自動(dòng)載入py3虛擬環(huán)境(以后只要進(jìn)入這個(gè)目錄就是Py3的環(huán)境)
(py3) [root@jumpserver opt]# unzip autoenv.zip 
(py3) [root@jumpserver opt]# echo "source /opt/autoenv/activate.sh" >> /root/.bashrc
(py3) [root@jumpserver opt]# . ~/.bashrc 

三、安裝Jumpserver

(py3) [root@jumpserver opt]# unzip jumpserver.zip 
(py3) [root@jumpserver opt]#  echo "source /opt/py3/bin/activate" > /opt/jumpserver/.env
(py3) [root@jumpserver opt]# cd jumpserver/
autoenv:
autoenv: WARNING:
autoenv: This is the first time you are about to source /opt/jumpserver/.env:
autoenv:
autoenv:   --- (begin contents) ---------------------------------------
autoenv:     source /opt/py3/bin/activate$
autoenv:
autoenv:   --- (end contents) -----------------------------------------
autoenv:
autoenv: Are you sure you want to allow this? (y/N) y   #這里輸入“y”,以便自動(dòng)載入py3環(huán)境
(py3) [root@jumpserver jumpserver]# cd requirements/
(py3) [root@jumpserver requirements]# yum -y install $(cat rpm_requirements.txt)
(py3) [root@jumpserver requirements]# pip install --upgrade pip
(py3) [root@jumpserver requirements]# pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/

四、安裝MySQLRedis

#安裝MySQL
(py3) [root@jumpserver requirements]# yum -y install mariadb*
(py3) [root@jumpserver requirements]# systemctl start mariadb
(py3) [root@jumpserver requirements]# mysqladmin -u root password 123.com
(py3) [root@jumpserver requirements]# mysql -u root -p123.com
MariaDB [(none)]> create database jumpserver default charset 'utf8' ;
MariaDB [(none)]> grant all on jumpserver.* to jumpserver@127.0.0.1 identified by '123.com';
#安裝Redis
(py3) [root@jumpserver ~]# yum -y install redis
(py3) [root@jumpserver ~]# systemctl start redis
(py3) [root@jumpserver ~]# netstat -anput | grep 6379
#修改jumpserver配置文件
(py3) [root@jumpserver ~]# cd /opt/jumpserver/
(py3) [root@jumpserver jumpserver]# cp config_example.yml config.yml 
#生成秘鑰令牌
(py3) [root@jumpserver jumpserver]# SECRET_KEY=`cat /dev/urandom | tr -dc A-Za-z0-9 | head -c 50`
(py3) [root@jumpserver jumpserver]# echo "SECRET_KEY=$SECRET_KEY" >> ~/.bashrc
(py3) [root@jumpserver jumpserver]# BOOTSTRAP_TOKEN=`cat /dev/urandom | tr -dc A-Za-z0-9 | head -c 16`
(py3) [root@jumpserver jumpserver]# echo "BOOTSTRAP_TOKEN=$BOOTSTRAP_TOKEN" >> ~/.bashrc
(py3) [root@jumpserver jumpserver]# sed -i "s/SECRET_KEY:/SECRET_KEY: $SECRET_KEY/g" /opt/jumpserver/config.yml
(py3) [root@jumpserver jumpserver]# sed -i "s/BOOTSTRAP_TOKEN:/BOOTSTRAP_TOKEN: $BOOTSTRAP_TOKEN/g" /opt/jumpserver/config.yml
(py3) [root@jumpserver jumpserver]# sed -i "s/# DEBUG: true/DEBUG: false/g" /opt/jumpserver/config.yml
(py3) [root@jumpserver jumpserver]# sed -i "s/# LOG_LEVEL: DEBUG/LOG_LEVEL: ERROR/g" /opt/jumpserver/config.yml
(py3) [root@jumpserver jumpserver]# sed -i "s/# SESSION_EXPIRE_AT_BROWSER_CLOSE: False/SESSION_EXPIRE_AT_BROWSER_CLOSE: true/g" /opt/jumpserver/config.yml 
(py3) [root@jumpserver jumpserver]# sed -i "s/DB_PASSWORD: /DB_PASSWORD: 123.com/g" /opt/jumpserver/config.yml
(py3) [root@jumpserver jumpserver]# echo -e "\033[31m 你的SECRET_KEY是 $SECRET_KEY \033[0m"
 你的SECRET_KEY是 Z6bUvXTZRpc73pnRp4qNwn1eMWNYrgzbEWkVJqIVXc6cXfpKDU 
(py3) [root@jumpserver jumpserver]# echo -e "\033[31m 你的BOOTSTRAP_TOKEN是 $BOOTSTRAP_TOKEN \033[0m"
 你的BOOTSTRAP_TOKEN是 aGXZtXKnhP3StNA3 
(py3) [root@jumpserver jumpserver]# egrep -v '^$|^#' config.yml     #確定配置文件修改無(wú)誤
SECRET_KEY: jS1ph0yvliBHdMV7YopAkBrEdIkZ3DjAq6HsftIPpQriNNBO2k
BOOTSTRAP_TOKEN: fUXgq00wg6XCD5lp
DEBUG: false
LOG_LEVEL: ERROR
SESSION_EXPIRE_AT_BROWSER_CLOSE: true
DB_ENGINE: mysql
DB_HOST: 127.0.0.1
DB_PORT: 3306
DB_USER: jumpserver
DB_PASSWORD: 123.com
DB_NAME: jumpserver
HTTP_BIND_HOST: 0.0.0.0
HTTP_LISTEN_PORT: 8080
REDIS_HOST: 127.0.0.1
REDIS_PORT: 6379
(py3) [root@jumpserver jumpserver]# ./jms start all -d    #啟動(dòng)jumpserver
(py3) [root@jumpserver jumpserver]# netstat -anpt | grep 8080
tcp        0      0 0.0.0.0:8080            0.0.0.0:*               LISTEN      17420/python3       

五、安裝配置coco組件

(py3) [root@jumpserver opt]# unzip coco.zip 
(py3) [root@jumpserver opt]# cd coco
(py3) [root@jumpserver coco]# echo "source /opt/py3/bin/activate" > /opt/coco/.env
(py3) [root@jumpserver coco]# cd requirements/
autoenv:
autoenv: WARNING:
autoenv: This is the first time you are about to source /opt/coco/.env:
autoenv:
autoenv:   --- (begin contents) ---------------------------------------
autoenv:     source /opt/py3/bin/activate$
autoenv:
autoenv:   --- (end contents) -----------------------------------------
autoenv:
autoenv: Are you sure you want to allow this? (y/N) y   #輸入“y”
(py3) [root@jumpserver requirements]# yum -y install $(cat rpm_requirements.txt)
(py3) [root@jumpserver requirements]# pip install -r requirements.txt
#修改配置文件
(py3) [root@jumpserver requirements]# cd ..
(py3) [root@jumpserver coco]# cp config_example.yml config.yml 
(py3) [root@jumpserver coco]# echo -e "\033[31m 你的BOOTSTRAP_TOKEN是 $BOOTSTRAP_TOKEN \033[0m"
#查看BOOTSTRAP_TOKEN的值
 你的BOOTSTRAP_TOKEN是 fUXgq00wg6XCD5lp 
 #注意,執(zhí)行下面的命令時(shí),需要自行修改為自己查看出來(lái)的值:
(py3) [root@jumpserver coco]# sed -i 's/BOOTSTRAP_TOKEN: <PleasgeChangeSameWithJumpserver>/BOOTSTRAP_TOKEN: fUXgq00wg6XCD5lp/g' config.yml 
(py3) [root@jumpserver coco]# sed -i 's/# LOG_LEVEL: INFO/LOG_LEVEL: ERROR/g' config.yml 
(py3) [root@jumpserver coco]# egrep -v '^$|^#' config.yml    #確定修改的配置文件
CORE_HOST: http://127.0.0.1:8080
BOOTSTRAP_TOKEN: fUXgq00wg6XCD5lp
LOG_LEVEL: ERROR
#后臺(tái)啟動(dòng)coco
(py3) [root@jumpserver coco]# ./cocod start -d

六、安裝guacamole及l(fā)una

這里采用docker容器的方式部署。
#部署docker環(huán)境
(py3) [root@jumpserver ~]# yum install -y yum-utils device-mapper-persistent-data lvm2
(py3) [root@jumpserver ~]# yum-config-manager  --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
(py3) [root@jumpserver ~]# yum makecache fast
(py3) [root@jumpserver ~]# yum -y install docker-ce
(py3) [root@jumpserver ~]# systemctl start docker
(py3) [root@jumpserver ~]# docker load  --input guacamole.tar
#啟動(dòng)容器
(py3) [root@jumpserver ~]# 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://192.168.10.8:8080 jumpserver/guacamole:latest
(py3) [root@jumpserver ~]# netstat -anput | grep 8081   #確定端口在監(jiān)聽
tcp6       0      0 :::8081                 :::*                    LISTEN      19162/docker-proxy  
(py3) [root@jumpserver ~]# tar zxf luna.tar.gz -C /opt/    #將luna解壓至/opt

七、安裝Nginx

(py3) [root@jumpserver /]# tar zxf nginx-1.2.4.tar.gz -C /usr/src
(py3) [root@jumpserver /]# cd /usr/src/nginx-1.2.4/
(py3) [root@jumpserver nginx-1.2.4]# ./configure --prefix=/usr/local/nginx && make && make install
(py3) [root@jumpserver nginx-1.2.4]# ln -sf /usr/local/nginx/sbin/nginx /usr/local/bin/
(py3) [root@jumpserver nginx-1.2.4]# cd /usr/local/nginx/conf/
(py3) [root@jumpserver conf]# mv nginx.conf nginx.conf.bak
(py3) [root@jumpserver conf]# rz    #上傳我提供的Nginx配置文件
(py3) [root@jumpserver conf]# ls | grep nginx.conf
nginx.conf     #在博文開頭的網(wǎng)盤鏈接中有此文件
nginx.conf.bak
nginx.conf.default
(py3) [root@jumpserver conf]# nginx -t     #確定Nginx配置無(wú)誤
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
(py3) [root@jumpserver conf]# nginx     #啟動(dòng)Nginx

八、Client訪問測(cè)試
訪問Nginx服務(wù)器的IP地址,即可看到登錄頁(yè)面(默認(rèn)用戶名及密碼都是“admin”):
jumpserver堡壘機(jī)的安裝部署
1、創(chuàng)建用戶
jumpserver堡壘機(jī)的安裝部署
jumpserver堡壘機(jī)的安裝部署
2、創(chuàng)建管理用戶
jumpserver堡壘機(jī)的安裝部署
jumpserver堡壘機(jī)的安裝部署
3、創(chuàng)建系統(tǒng)用戶
用戶名盡量為root,選擇手動(dòng)登錄,這個(gè)用戶是用來(lái)連接后端資產(chǎn)的。
jumpserver堡壘機(jī)的安裝部署
jumpserver堡壘機(jī)的安裝部署
4、創(chuàng)建資產(chǎn)
我這里啟動(dòng)了一臺(tái)IP為192.168.20.4的主機(jī)來(lái)作為后端資產(chǎn),以便測(cè)試。
jumpserver堡壘機(jī)的安裝部署
jumpserver堡壘機(jī)的安裝部署
5、創(chuàng)建授權(quán)規(guī)則
jumpserver堡壘機(jī)的安裝部署
jumpserver堡壘機(jī)的安裝部署
6、連接后端資產(chǎn)測(cè)試
jumpserver堡壘機(jī)的安裝部署
jumpserver堡壘機(jī)的安裝部署

看完上述內(nèi)容,你們掌握安裝部署jumpserver堡壘機(jī)的方法了嗎?如果還想學(xué)到更多技能或想了解更多相關(guān)內(nèi)容,歡迎關(guān)注億速云行業(yè)資訊頻道,感謝各位的閱讀!

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI