博文結構
jumpserver介紹
安裝jumpserver前端
在特定網絡環境中(如內網和外網),爲了保證公司網絡中的服務器數據不受外界的和破壞,運用各類技術手段收集和監控公司服務器的狀態,安全時間、以便集中報警,而且及時處理。
咱們又把堡壘機叫作跳板機,簡易的跳板機功能簡單,主要核心功能是遠程登錄服務器和日誌審計比較優秀的開源軟件jumpserver,功能齊全如: 認證、受權、審計、自動化、資產管理(內網服務器資源分配)等。python
1.徹底開源;
2.Python編寫,易於二次開發
3.實現跳板機的基本功能、認證、受權、審計
4.集成了Ansiable,實現批量操做命令等
5.支持web終端
6.Bootstrap編寫,界面美觀
7.自動收集硬件信息
8.錄像回放、命令搜索、實時監控mysql
用戶經過瀏覽器訪問到nginx代理服務器頁面,nginx服務器在jump架構中是做爲一臺代理服務器,用來代理jumpserver程序、coco程序、luna程序、guacamole程序的web頁面,方便用戶使用,若是不採用nginx作代理服務器的話,用戶訪問頁面時比較麻煩(如coco程序須要用到8080端口、guncamole須要別的端口,使用起來不方便,並且後續的頁面跳轉有可能會致使not found),nginx調取luna程序設置終端採用ssh協議鏈接後端資產(後端服務器)。linux
Jumpserver:jumpserver的管理後臺
Coco:實現了ssh server 和 web終端的組件,提供ssh和websocket接口
Luna:是web Terminal 的前端(用來展現給用戶和與用戶進行交互)前端頁面都是由該項目完成的
Guacamole:apache的跳板機項目,jumpserver使用其組件實現RDP(遠程桌面)功,能,jumpserver在guacamole中添加額外插件,不修改其自己,實現調用nginx
下載軟件包git
安裝硬件介紹centos 7 4G以上內存 至少雙核處理器
安裝依賴環境:python3.6以上版本 後端數據庫 redis github
[root@localhost ~]# localedef -c -f UTF-8 -i zh_CN zh_CN.UTF-8 // -c 強制執行 -f 指定設置的字符集 -i 從那個源 [root@localhost ~]# export LC_ALL=zh_CN.UTF-8 // 將字符集設置成環境變量 [root@localhost ~]# echo 'LANG="zh_CN.UTF-8"' > /etc/locale.conf // 加入到字符配置文件
[root@bogon ~]# yum -y install wget sqlite-devel xz gcc automake zlib-devel openssl-devel epel-release git [root@bogon ~]# tar xf Python-3.6.1.tar.xz -C /usr/src/ [root@bogon ~]# cd /usr/src/Python-3.6.1/ [root@bogon Python-3.6.1]# ./configure && make && make install
[root@bogon ~]# cd /opt/ [root@bogon opt]# python3 -m venv py3 // venv python中的虛擬環境 py3虛擬環境名稱 [root@bogon opt]# source /opt/py3/bin/activate (py3) [root@bogon opt]#
(py3) [root@bogon opt]# cd /opt/ (py3) [root@bogon opt]# git clone https://github.com/kennethreitz/autoenv.git //將github網站的項目克隆到本地 項目路徑https://github.com/kennethreitz/autoenv 正克隆到 'autoenv'... remote: Enumerating objects: 16, done. remote: Counting objects: 100% (16/16), done. remote: Compressing objects: 100% (13/13), done. remote: Total 688 (delta 5), reused 9 (delta 3), pack-reused 672 接收對象中: 100% (688/688), 111.91 KiB | 108.00 KiB/s, done. 處理 delta 中: 100% (362/362), done. (py3) [root@bogon opt]# echo 'source /opt/autoenv/activate.sh' >> /root/.bashrc (py3) [root@bogon opt]# source ~/.bashrc (py3) [root@bogon opt]#
(py3) [root@bogon requirements]# unzip jumpserver.zip (py3) [root@bogon requirements]# echo "source /opt/py3/bin/activate" > /opt/jumpserver/.env (py3) [root@bogon requirements]# cd jumpserver/ //安裝依賴包rpm //輸入y (py3) [root@bogon requirements]# yum -y install $(cat rpm_requirements.txt) (py3) [root@bogon requirements]# pip install --upgrade pip Collecting pip Downloading https://files.pythonhosted.org/packages/54/0c/d01aa759fdc501a58f431eb594a17495f15b88da142ce14b5845662c13f3/pip-20.0.2-py2.py3-none-any.whl (1.4MB) 100% |████████████████████████████████| 1.4MB 883kB/s Installing collected packages: pip Found existing installation: pip 9.0.1 Uninstalling pip-9.0.1: Successfully uninstalled pip-9.0.1 Successfully installed pip-20.0.2 (py3) [root@bogon requirements]# pip install wheel Collecting wheel Downloading wheel-0.34.2-py2.py3-none-any.whl (26 kB) Installing collected packages: wheel Successfully installed wheel-0.34.2 (py3) [root@bogon requirements]# pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/ //pip install <安裝包名> -r 將文件裏面的內容看成安裝包 -i 指定鏈接下載安裝包 Pip是python中安裝軟件包的命令,至關於yum命令 (安裝須要等待幾分鐘)
(py3) [root@bogon requirements]# yum -y install mariadb mariadb-devel mariadb-server (py3) [root@bogon requirements]# systemctl start mariadb (py3) [root@bogon requirements]# mysqladmin -u root password 1234.com (py3) [root@bogon requirements]# mysql -u root -p1234.com //登錄數據庫建立jumpserver庫用來存放jumpserver數據 MariaDB [(none)]> create database jumpserver default charset 'utf8' ; //建立一個名爲jumpserver的數據庫 MariaDB [(none)]> grant all on jumpserver.* to jumpserver@127.0.0.1 identified by '1234.com'; //jumpserver對數據庫擁有全部權限,密碼爲123.com MariaDB [(none)]> flush privileges; MariaDB [(none)]> exit (py3) [root@bogon requirements]# ss -lnt | grep 3306 LISTEN 0 50 *:3306 *:*
(py3) [root@bogon requirements]# yum -y install redis (py3) [root@bogon requirements]# systemctl start redis (py3) [root@bogon requirements]# netstat -anpt | grep redis tcp 0 0 127.0.0.1:6379 0.0.0.0:* LISTEN 75890/redis-server
(py3) [root@bogon requirements]# cd /opt/jumpserver/ (py3) [root@bogon jumpserver]# cp config_example.yml config.yml //生成SECRET_KEY寫入配置文件 (py3) [root@bogon jumpserver]# cat /dev/urandom | tr -dc A-Za-z0-9 | head -c 50 //把這個命令生成得碼複製到配置文件 (py3) [root@bogon jumpserver]# cat /dev/urandom | tr -dc A-Za-z0-9 | head -c 16 //把這個命令生成得碼複製到配置文件
(py3) [root@bogon requirements]# unzip coco.zip (py3) [root@bogon requirements]# cd coco (py3) [root@bogon requirements]# echo "source /opt/py3/bin/activate" > /opt/coco/.env (py3) [root@bogon requirements]# cd requirements/ (py3) [root@bogon requirements]# yum -y install $(cat rpm_requirements.txt) (py3) [root@bogon requirements]# pip install -r requirements.txt (py3) [root@bogon requirements]# cd .. (py3) [root@bogon coco]# cp config_example.yml config.yml (py3) [root@bogon coco]# vim /opt/jumpserver/config.yml //把這個文件中得16位碼複製上 (py3) [root@bogon coco]# vim config.yml
(py3) [root@bogon coco]# ./cocod start -d Use eventlet dispatch Start coco process (py3) [root@bogon coco]# netstat -anpt | grep 2222 tcp 0 0 0.0.0.0:2222 0.0.0.0:* LISTEN 33439/python3
(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 < guacamole.tar (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.1.10:8080 \ jumpserver/guacamole:latest (py3) [root@jumpserver ~]# ss -lnt | grep 8081 LISTEN 0 128 :::8081 :::* (py3) [root@jumpserver ~]# tar zxf luna.tar.gz -C /opt
(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 && 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]# cp nginx.conf nginx.conf.bak (py3) [root@jumpserver conf]# mv /root/nginx.conf . mv:是否覆蓋"./nginx.conf"? y //博文開頭得軟件包中得nginx.conf複製到這個nginx主配置文件中就能夠了 (py3) [root@jumpserver conf]# nginx -t 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 (py3) [root@jumpserver conf]# ss -lnt | grep -w 80 LISTEN 0 128 *:80 *: ``
實驗環境,因此就開啓一臺虛擬機192.168.1.131做爲測試(web頁面的客戶端與後端資產確定不在同一網段,由於用戶是經過公網登陸到jumpserver才能夠對後端服務器進行操做的)!web