您好,登錄后才能下訂單哦!
一、jumpserver介紹
官網www.jumpserver.org
Jumpserver是一款使用Python, Django開發的開源跳板機系統, 助力互聯網企業。
高效,用戶、資產、權限、審計,管理。
Auth 統一認證
CMDB 資產管理
統一授權
日志審計
自動化運維(ansible)
v1.4.4,基于python3.6, django 1.11,目前還未開發完成,所以接下來將要安裝v1.4.4 。
二、安裝jumpserver
安裝(1.4.4)
首先進入GitHub,左上角搜索jumpserver,搜出來了:
? jumpserver/jumpserver
? Jumpserver是全球首款完全開源的堡壘機,是符合 4A 的專業運維審計系統。
點擊進入,選擇標簽,可以看到最新版本到了v1.4.10,往下看,可以看到安裝及使用指南,點擊step by step安裝文檔→一站式、分布式安裝文檔→一體化部署文檔(基于CentOS 7)→在線安裝文檔。
我這里使用的是centos7,先yum update -y將centos升級到最新版本。
內存至少2G,不然跑不起來,MySQL高于5.6;
放行80、8080、2222端口,或者關掉firewalld:
#?firewall-cmd?--zone=public?--add-port=80/tcp?--permanent #?firewall-cmd?--zone=public?--add-port=2222/tcp?--permanent #?firewall-cmd?--zone=public?--add-port=8080/tcp?--permanent
不讓它開機啟動;把selinux關閉。
# 修改字符集:
#?localedef?-c?-f?UTF-8?-i?zh_CN?zh_CN.UTF-8 #?export?LC_ALL=zh_CN.UTF-8 #?echo?$LC_ALLzh_CN.UTF-8 #?cat?/etc/locale.conf????//查看字符集是否為UTF-8 LANG="zh_CN.UTF-8"
1、準備Python3和虛擬環境
# 編譯或者yum安裝都可以, 版本要求參考環境要求,centos默認自帶的Python是2.7,所以需要額外安裝一個Python3.6。
安裝Python3.6、Redis、MySQL
#?yum?update?-y?將系統升級到最新,update不行就用yum?upgrade?-y #?cat?/etc/redhat-release???//此時最新版7.7 CentOS?Linux?release?7.7.1908?(Core) #?yum?install?-y?wget?epel-release?gcc?git #?yum?install?-y?python36?python36-devel #?yum?install?-y?redis #?systemctl?enable?redis #?systemctl?start?redis #?yum?install?-y?mariadb?mariadb-devel?mariadb-server #?systemctl?enable?mariadb #?systemctl?start?mariadb #?mysql?-uroot >?create?database?jumpserver?default?charset?'utf8'; >?grant?all?on?jumpserver.*?to?'jumpserver'@'127.0.0.1'?identified?by?'weakpassword'; >?flush?privileges; >?quit
2、創建py3虛擬環境
#?cd?/opt/ #?python3.6?-m?venv?/opt/py3
3、載入py3的虛擬環境
#?每次操作?jumpserver?都需要使用下面的命令載入?py3?虛擬環境 #?source?/opt/py3/bin/activate #?部分系統可能會提示?source:?not?found?,?可以使用?"."?代替?"source" (py3)?[root@wbs?opt]#???????//載入以后會有一個py3的前綴
4、獲取jumpserver代碼
$?cd?/opt $?git?clone?--depth=1?https://github.com/jumpserver/jumpserver.git #?如果沒有安裝?git?請先安裝 #?echo?"source?/opt/py3/bin/activate"?>?/opt/jumpserver/.env??//進入jumpserver目錄時自動載入py3虛擬環境。
5、安裝依賴包
$?cd?/opt/jumpserver/requirements $?yum?install?-y?$(cat?rpm_requirements.txt) 安裝Python庫依賴: $?pip?install?--upgrade?pip?setuptools???//把setup工具升級 $?pip?install?-r?requirements.txt #?確保已經載入?py3?虛擬環境,?中間如果遇到報錯一般是依賴包沒裝全,?可以通過?搜索引擎?解決 pip命令類似于系統里的yum
6、修改配置文件
$?cd?/opt/jumpserver $?cp?config_example.yml?config.yml $?vim?config.yml #?注意?SECRET_KEY?和?BOOTSTRAP_TOKEN?不能使用純數字字符串 定義SECRET_KEY,不能為空。使用這條命令生成隨機字符串: cat?/dev/urandom?|?tr?-dc?A-Za-z0-9?|?head?-c?49;echo 到命令行輸出后再復制粘貼進去。 定義BOOTSTRAP_TOKEN,不能為空。使用這條命令生成隨機字符串: cat?/dev/urandom?|?tr?-dc?A-Za-z0-9?|?head?-c?16;echo #?MySQL?or?postgres?setting?like: #?使用Mysql作為數據庫 DB_ENGINE:?mysql DB_HOST:?127.0.0.1 DB_PORT:?3306 DB_USER:?jumpserver DB_PASSWORD:?waakpassword??//定義密碼 DB_NAME:?jumpserver #將Redis下面三行的#號去掉 #?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
7、生成數據庫表結構和初始化數據
#?cd?/opt/jumpserver/utils #?sh?make_migrations.sh
8、運行jumpserver
$?cd?/opt/jumpserver $?./jms?start?-d???#加-d?參數在后臺運行?./jms?start?-d,不然在前臺會輸出很多東西。 使用方式:./jms?start|stop|status|restart #?netstat?-lntp?|grep?8080 tcp????????0??????0?0.0.0.0:8080????????????0.0.0.0:*???????????????LISTEN??????27161/python3.6 #如果想讓它開機啟動,把這一條命令加到/etc/rc.local里去。 #?vim?/etc/rc.local source?/opt/py3/bin/activate;?cd?/opt/jumpserver;?./jms?start?-d?&>?/dev/null
此時可以到瀏覽器訪問本機的IP:8080端口,可以看到jumpserver的登錄頁面。如果看不到頁面,可能是firewalld沒放行,線上機器想辦法把端口放行。默認賬號和密碼:admin。
9、部署koko組件
$?cd?/opt #?訪問?https://github.com/jumpserver/koko/releases?下載對應?release?包并解壓到?/opt目錄 $?wget?https://github.com/jumpserver/koko/releases/download/1.5.3/koko-master-linux-amd64.tar.gz $?tar?xf?koko-master-linux-amd64.tar.gz $?chown?-R?root:root?kokodir $?cd?kokodir $?cp?config_example.yml?config.yml $?vim?config.yml #?BOOTSTRAP_TOKEN?需要從?jumpserver/config.yml?里面獲取,?保證一致 $?./koko?-d??#?一定要加-d讓它在后臺運行,運行后可以netstat?-lntp查看到端口2222和5000起來了。
10、安裝luna組件
$?cd?/opt $?wget?https://github.com/jumpserver/luna/releases/download/1.5.3/luna.tar.gz $?tar?xf?luna.tar.gz $?chown?-R?root:root?luna
11、配置Nginx整合各組件
$?yum?install?-y?nginx $?vim?/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?{ #????????} #????} ...
$?rm?-rf?/etc/nginx/conf.d/default.conf $?vim?/etc/nginx/conf.d/jumpserver.conf server?{ ????listen?80; ????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/;??#?靜態資源,?如果修改安裝目錄,?此處需要修改 ????} ????location?/koko/?{ ????????proxy_pass???????http://localhost:5000; ????????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?/guacamole/?{ ????????proxy_pass???????http://localhost: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?/ws/?{ ????????proxy_set_header?X-Real-IP?$remote_addr; ????????proxy_set_header?Host?$host; ????????proxy_set_header?X-Forwarded-For?$proxy_add_x_forwarded_for; ????????proxy_pass?http://localhost:8070; ????????proxy_http_version?1.1; ????????proxy_buffering?off; ????????proxy_set_header?Upgrade?$http_upgrade; ????????proxy_set_header?Connection?"upgrade"; ????} ????location?/?{ ????????proxy_pass?http://localhost: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; ????} }
$?nginx?-t????#?確保配置沒有問題,?有問題請先解決 $?systemctl?start?nginx $?systemctl?enable?nginx #?測試連接 $?ssh?-p2222?admin@192.168.149.131 密碼admin,如果能登錄代表部署成功,web界面如不能登錄,換個瀏覽器試試。
三、登錄jumpserver
1、更改密碼
web界面admin登錄→個人信息→更改密碼
更改密碼后重新登錄。
2、密碼登錄
新建一個會話,主機名定義好IP,端口2222,用戶名密碼定義好,登錄即可直接進入jumpserver。
3、密鑰登錄
# cat .ssh/authorized_keys
把authorized_keys的公鑰放到web界面中個人信息的ssh密鑰里,提交。
再到命令行下就可以通過密鑰登錄了。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。