關(guān)于centos7搭建jumpserver

關(guān)于jumpserver的安裝

這段時(shí)間沒事做、看了一下有關(guān)職位的技能需求的信息,就有了今天的測(cè)試。

環(huán)境centos7

ip 192.168.1.114

firewall-cmd --zone=public --add-port=80/tcp --permanent? # nginx 端口

firewall-cmd --zone=public --add-port=2222/tcp --permanent? # 用戶SSH登錄端口 coco

firewall-cmd --reload? # 重新載入規(guī)則

setenforce 0

sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config

# 修改字符集, 否則可能報(bào) input/output error的問題, 因?yàn)槿罩纠锎蛴×酥形?/p>

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

準(zhǔn)備python3和python虛擬環(huán)境

yum -y install wget gcc epel-release git

wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

yum -y install python36 python36-devel

建立python虛擬環(huán)境

cd /opt

python3.6 -m venv py3

source /opt/py3/bin/activate

# 看到下面的提示符代表成功, 以后運(yùn)行 Jumpserver 都要先運(yùn)行以上 source 命令, 以下所有命令均在該虛擬環(huán)境中運(yùn)行

(py3) [root@localhost py3]

安裝jumpserver

下載項(xiàng)目

cd /opt/

git clone https://github.com/jumpserver/jumpserver.git

安裝依賴rpm包

cd /opt/jumpserver/requirements

yum -y install $(cat rpm_requirements.txt)

安裝python庫依賴

pip install --upgrade pip setuptools -i https://mirrors.aliyun.com/pypi/simple/

pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/

安裝redis ,jumpserver使用redis做cache和celery broke

yum -y install redis

systemctl enable redis

systemctl start redis

安裝MySQL

yum -y install mariadb mariadb-devel mariadb-server # centos7下安裝的是mariadb

systemctl enable mariadb

systemctl start mariadb

創(chuàng)建數(shù)據(jù)庫jumpserver并授權(quán)

DB_PASSWORD=`cat /dev/urandom | tr -dc A-Za-z0-9 | head -c 24`? # 生成隨機(jī)數(shù)據(jù)庫密碼

echo -e "\033[31m 你的數(shù)據(jù)庫密碼是 $DB_PASSWORD \033[0m"(uvmVvw6pjaVaQmgxICCESWtM )

mysql -uroot -e "create database jumpserver default charset 'utf8'; grant all on jumpserver.* to 'jumpserver'@'127.0.0.1' identified by '$DB_PASSWORD'; flush privileges;"

修改jumpserver配置文件

cd /opt/jumpserver/

cp config_example.yml config.yml

SECRET_KEY=`cat /dev/urandom | tr -dc A-Za-z0-9 | head -c 50`? # 生成隨機(jī)SECRET_KEY

echo "SECRET_KEY=$SECRET_KEY" >> ~/.bashrc

BOOTSTRAP_TOKEN=`cat /dev/urandom | tr -dc A-Za-z0-9 | head -c 16`? # 生成隨機(jī)BOOTSTRAP_TOKEN

echo "BOOTSTRAP_TOKEN=$BOOTSTRAP_TOKEN" >> ~/.bashrc

sed -i "s/SECRET_KEY:/SECRET_KEY: $SECRET_KEY/g" /opt/jumpserver/config.yml

sed -i "s/BOOTSTRAP_TOKEN:/BOOTSTRAP_TOKEN: $BOOTSTRAP_TOKEN/g" /opt/jumpserver/config.yml

sed -i "s/# DEBUG: true/DEBUG: false/g" /opt/jumpserver/config.yml

sed -i "s/# LOG_LEVEL: DEBUG/LOG_LEVEL: ERROR/g" /opt/jumpserver/config.yml

sed -i "s/# SESSION_EXPIRE_AT_BROWSER_CLOSE: false/SESSION_EXPIRE_AT_BROWSER_CLOSE: true/g" /opt/jumpserver/config.yml

sed -i "s/DB_PASSWORD: /DB_PASSWORD: $DB_PASSWORD/g" /opt/jumpserver/config.yml

echo -e "\033[31m 你的SECRET_KEY是 $SECRET_KEY \033[0m"

你的SECRET_KEY是 hhOjUGFcJxji2S9QCCUBUrorokMEu2IIPZeA57bHAEpJ9GdfHY

echo -e "\033[31m 你的BOOTSTRAP_TOKEN是 $BOOTSTRAP_TOKEN \033[0m"

你的BOOTSTRAP_TOKEN是 ji1BuPp7T1oblqyv

vi config.yml

# SECURITY WARNING: keep the secret key used in production secret!

# 加密秘鑰 生產(chǎn)環(huán)境中請(qǐng)修改為隨機(jī)字符串, 請(qǐng)勿外泄

SECRET_KEY:

# SECURITY WARNING: keep the bootstrap token used in production secret!

# 預(yù)共享Token coco和guacamole用來注冊(cè)服務(wù)賬號(hào), 不在使用原來的注冊(cè)接受機(jī)制

BOOTSTRAP_TOKEN:

# Development env open this, when error occur display the full process track, Production disable it

# DEBUG 模式 開啟DEBUG后遇到錯(cuò)誤時(shí)可以看到更多日志

DEBUG: false

# DEBUG, INFO, WARNING, ERROR, CRITICAL can set. See https://docs.djangoproject.com/en/1.10/topics/logging/

# 日志級(jí)別

LOG_LEVEL: ERROR

# LOG_DIR:

# Session expiration setting, Default 24 hour, Also set expired on on browser close

# 瀏覽器Session過期時(shí)間, 默認(rèn)24小時(shí), 也可以設(shè)置瀏覽器關(guān)閉則過期

# SESSION_COOKIE_AGE: 86400

SESSION_EXPIRE_AT_BROWSER_CLOSE: true

# Database setting, Support sqlite3, mysql, postgres ....

# 數(shù)據(jù)庫設(shè)置

# See https://docs.djangoproject.com/en/1.10/ref/settings/#databases

# SQLite setting:

# 使用單文件sqlite數(shù)據(jù)庫

# DB_ENGINE: sqlite3

# DB_NAME:

# MySQL or postgres setting like:

# 使用Mysql作為數(shù)據(jù)庫

DB_ENGINE: mysql

DB_HOST: 127.0.0.1

DB_PORT: 3306

DB_USER: jumpserver

DB_PASSWORD:

DB_NAME: jumpserver

# When Django start it will bind this host and port

# ./manage.py runserver 127.0.0.1:8080

# 運(yùn)行時(shí)綁定端口

HTTP_BIND_HOST: 0.0.0.0

HTTP_LISTEN_PORT: 8080

# Use Redis as broker for celery and web socket

# Redis配置

REDIS_HOST: 127.0.0.1

REDIS_PORT: 6379

# REDIS_PASSWORD:

# REDIS_DB_CELERY: 3

# REDIS_DB_CACHE: 4

# Use OpenID authorization

# 使用OpenID 來進(jìn)行認(rèn)證設(shè)置

# BASE_SITE_URL: http://localhost:8080

# AUTH_OPENID: false? # True or False

# AUTH_OPENID_SERVER_URL: https://openid-auth-server.com/

# AUTH_OPENID_REALM_NAME: realm-name

# AUTH_OPENID_CLIENT_ID: client-id

# AUTH_OPENID_CLIENT_SECRET: client-secret

# OTP settings

# OTP/MFA 配置

# OTP_VALID_WINDOW: 0

# OTP_ISSUER_NAME: Jumpserver

運(yùn)行jumpserver

cd /opt/jumpserver/

./jms start all -d #后臺(tái)運(yùn)行使用-d

安裝ssh server和websocket server:Coco

下載項(xiàng)目

cd /opt

source /opt/py3/bin/activate

git clone https://github.com/jumpserver/coco.git

安裝依賴

cd /opt/coco/requirements

yum -y install $(cat rpm_requirements.txt)

pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/

修改配置文件并運(yùn)行

cd /opt/coco

cp config_example.yml config.yml

sed -i "s/BOOTSTRAP_TOKEN: <PleasgeChangeSameWithJumpserver>/BOOTSTRAP_TOKEN: $BOOTSTRAP_TOKEN/g" /opt/coco/config.yml

sed -i "s/# LOG_LEVEL: INFO/LOG_LEVEL: ERROR/g" /opt/coco/config.yml

vi config.yml

# 項(xiàng)目名稱, 會(huì)用來向Jumpserver注冊(cè), 識(shí)別而已, 不能重復(fù)

# NAME: {{ Hostname }}

# Jumpserver項(xiàng)目的url, api請(qǐng)求注冊(cè)會(huì)使用

CORE_HOST: http://127.0.0.1:8080

# Bootstrap Token, 預(yù)共享秘鑰, 用來注冊(cè)coco使用的service account和terminal

# 請(qǐng)和jumpserver 配置文件中保持一致, 注冊(cè)完成后可以刪除

BOOTSTRAP_TOKEN: <PleasgeChangeSameWithJumpserver>

# 啟動(dòng)時(shí)綁定的ip, 默認(rèn) 0.0.0.0

# BIND_HOST: 0.0.0.0

# 監(jiān)聽的SSH端口號(hào), 默認(rèn)2222

# SSHD_PORT: 2222

# 監(jiān)聽的HTTP/WS端口號(hào), 默認(rèn)5000

# HTTPD_PORT: 5000

# 項(xiàng)目使用的ACCESS KEY, 默認(rèn)會(huì)注冊(cè), 并保存到 ACCESS_KEY_STORE中,

# 如果有需求, 可以寫到配置文件中, 格式 access_key_id:access_key_secret

# ACCESS_KEY: null

# ACCESS KEY 保存的地址, 默認(rèn)注冊(cè)后會(huì)保存到該文件中

# ACCESS_KEY_STORE: data/keys/.access_key

# 加密密鑰

# SECRET_KEY: null

# 設(shè)置日志級(jí)別 [DEBUG, INFO, WARN, ERROR, FATAL, CRITICAL]

LOG_LEVEL: ERROR

# 日志存放的目錄

# LOG_DIR: logs

# SSH白名單

# ALLOW_SSH_USER: all

# SSH黑名單, 如果用戶同時(shí)在白名單和黑名單, 黑名單優(yōu)先生效

# BLOCK_SSH_USER:

#? -

# 和Jumpserver 保持心跳時(shí)間間隔

# HEARTBEAT_INTERVAL: 5

# Admin的名字, 出問題會(huì)提示給用戶

# ADMINS: ''

# SSH連接超時(shí)時(shí)間 (default 15 seconds)

# SSH_TIMEOUT: 15

# 語言 [en, zh]

# LANGUAGE_CODE: zh

# SFTP的根目錄, 可選 /tmp, Home其他自定義目錄

# SFTP_ROOT: /tmp

# SFTP是否顯示隱藏文件

# SFTP_SHOW_HIDDEN_FILE: false

$ ./cocod start -d? # 后臺(tái)運(yùn)行使用 -d 參數(shù)./cocod start -d

安裝web Terminal 前端 :luna

cd /opt

wget https://github.com/jumpserver/luna/releases/download/1.4.8/luna.tar.gz#(這里如果網(wǎng)速慢、建議下載到本地再上傳到服務(wù)器,我這里上傳到百度云了鏈接:https://pan.baidu.com/s/1J1JxQkhMK83PGE8fyEwsjA 提取碼:iiv1 復(fù)制這段內(nèi)容后打開百度網(wǎng)盤手機(jī)App,操作更方便哦)

tar xf luna.tar.gz

chown -R root:root luna

安裝windows支持組件

mkdir /usr/local/lib/freerdp/

ln -s /usr/local/lib/freerdp /usr/lib64/freerdp

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 freerdp-plugins pango-devel libssh2-devel libtelnet-devel libvncserver-devel pulseaudio-libs-devel openssl-devel libvorbis-devel libwebp-devel ghostscript

編譯安裝guacamole

cd /opt

git clone https://github.com/jumpserver/docker-guacamole.git

cd /opt/docker-guacamole/

tar -xf guacamole-server-0.9.14.tar.gz

cd guacamole-server-0.9.14

autoreconf -fi

./configure --with-init-dir=/etc/init.d

make && make install

cd ..

rm -rf guacamole-server-0.9.14

l

配置Tomcat

mkdir -p /config/guacamole /config/guacamole/lib /config/guacamole/extensions? # 創(chuàng)建 guacamole 目錄

ln -sf /opt/docker-guacamole/guacamole-auth-jumpserver-0.9.14.jar /config/guacamole/extensions/guacamole-auth-jumpserver-0.9.14.jar

ln -sf /opt/docker-guacamole/root/app/guacamole/guacamole.properties /config/guacamole/guacamole.properties? # guacamole 配置文件

cd /config

wget http://mirror.bit.edu.cn/apache/tomcat/tomcat-8/v8.5.38/bin/apache-tomcat-8.5.38.tar.gz

tar xf apache-tomcat-8.5.38.tar.gz

rm -rf apache-tomcat-8.5.38.tar.gz

mv apache-tomcat-8.5.38 tomcat8

rm -rf /config/tomcat8/webapps/*

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? # 修改默認(rèn)端口為 8081

sed -i 's/FINE/WARNING/g' /config/tomcat8/conf/logging.properties? # 修改 log 等級(jí)為 WARNING

cd /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

配置環(huán)境變量

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

# BOOTSTRAP_TOKEN 為 Jumpserver/config.yml 里面的 BOOTSTRAP_TOKEN

export BOOTSTRAP_TOKEN=$BOOTSTRAP_TOKEN

echo "export BOOTSTRAP_TOKEN=$BOOTSTRAP_TOKEN" >> ~/.bashrc

export JUMPSERVER_KEY_DIR=/config/guacamole/keys

echo "export JUMPSERVER_KEY_DIR=/config/guacamole/keys" >> ~/.bashrc

export GUACAMOLE_HOME=/config/guacamole

echo "export GUACAMOLE_HOME=/config/guacamole" >> ~/.bashrc

啟動(dòng)guacamole

/etc/init.d/guacd start

sh /config/tomcat8/bin/startup.sh

配置nginx整合各組件

$ yum install yum-utils

$ vi /etc/yum.repos.d/nginx.repo

[nginx-stable]

name=nginx stable repo

baseurl=http://nginx.org/packages/centos/$releasever/$basearch/

gpgcheck=1

enabled=1

gpgkey=https://nginx.org/keys/nginx_signing.key

yum install -y nginx

rm -rf /etc/nginx/conf.d/default.conf

systemctl enable nginx

準(zhǔn)備配置文件需改/etc/nginx/conf.d/jumpserver.conf

vi /etc/nginx/conf.d/jumpserver.conf

server {

? ? listen 80;? # 代理端口, 以后將通過此端口進(jìn)行訪問, 不再通過8080端口

? ? # server_name demo.jumpserver.org;? # 修改成你的域名或者注釋掉

? ? client_max_body_size 100m;? # 錄像及文件上傳大小限制

? ? location /luna/ {

? ? ? ? try_files $uri / /index.html;

? ? ? ? alias /opt/luna/;? # luna 路徑, 如果修改安裝目錄, 此處需要修改

? ? }

? ? location /media/ {

? ? ? ? add_header Content-Encoding gzip;

? ? ? ? root /opt/jumpserver/data/;? # 錄像位置, 如果修改安裝目錄, 此處需要修改

? ? }

? ? location /static/ {

? ? ? ? root /opt/jumpserver/data/;? # 靜態(tài)資源, 如果修改安裝目錄, 此處需要修改

? ? }

? ? location /socket.io/ {

? ? ? ? proxy_pass? ? ? http://localhost:5000/socket.io/;? # 如果coco安裝在別的服務(wù)器, 請(qǐng)?zhí)顚懰膇p

? ? ? ? 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安裝在別的服務(wù)器, 請(qǐng)?zhí)顚懰膇p

? ? ? ? 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安裝在別的服務(wù)器, 請(qǐng)?zhí)顚懰膇p

? ? ? ? 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安裝在別的服務(wù)器, 請(qǐng)?zhí)顚懰膇p

? ? ? ? proxy_set_header X-Real-IP $remote_addr;

? ? ? ? proxy_set_header Host $host;

? ? ? ? proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

? ? }

}

運(yùn)行nginx

# CentOS 7

systemctl start nginx

systemctl enable nginx


開始使用jumpserver

瀏覽器訪問本機(jī)ip

默認(rèn)用戶名admin

默認(rèn)密碼admin


登錄后的界面


僅供參考

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容