jumpserver 0.4.0 安裝使用


環境
系統: CentOS 7 
Server IP: 192.168.1.76

一. 準備Python3和Python虛擬環境
1.1 安裝依賴包
$ yum -y install wget sqlite-devel xz gcc automake zlib-devel openssl-devel git

1.2 編譯安裝
$ wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tar.xz
$ tar xvf Python-3.6.1.tar.xz && cd Python-3.6.1
$ ./configure && make && make install

1.3 建立python虛擬環境
因爲CentOS 6/7自帶的是Python2,而Yum等工具依賴原來的Python,爲了不擾亂原來的環境我們來使用Python虛擬環境
$ cd /opt
$ python3 -m venv py3
$ source /opt/py3/bin/activate# 看到下面的提示符代表成功,以後運行jumpserver都要先運行以上source命令,以下所有命令均在該虛擬環境中運行(py3) [root@localhost py3]#
二. 安裝Jumpserver 0.4.0
2.1 下載或clone項目
項目提交較多git clone時較大,你可以選擇去github項目頁面直接下載 zip包,我的網速好,我直接clone了
$ source /opt/py3/bin/activate
$ cd /opt/
$ git clone https://github.com/jumpserver/jumpserver.git

2.2 安裝依賴rpm包
$ cd /opt/jumpserver/requirements
$ yum -y install epel-release
$ yum -y install$(cat rpm_requirements.txt) # 如果沒有任何報錯請繼續

2.3 安裝python庫依賴
$ pip install -r requirements.txt # 如果沒有任何報錯請繼續

2.4 安裝Redis, jumpserver使用celery依賴
$ yum -y install redis
$ systemctl start redis && systemctl enable redis

2.5 安裝MySQL
本教程使用mysql作爲數據庫,如果不使用mysql可以跳過相關mysql安裝和配置# centos7
$ yum -y install mariadb mariadb-devel mariadb-server # centos7下安裝的是mariadb
$ systemctl start mariadb # centos6
$ yum -y install mysql mysql-devel mysql-server
$ service mysql start

2.6 創建數據庫 jumpserver並授權
$ mysql> create database jumpserver default charset 'utf8';
mysql> grant all on jumpserver.* to 'jumpserver'@'127.0.0.1' identified by 'longtel.com';
mysql> flush privileges;

2.7 安裝 python3 mysql驅動: mysqlclient
由於MySQLdb庫不支持 python3.5+,所以選擇了mysqlclient作爲驅動,pymysql使用python寫的,速度較慢
$ pip install mysqlclient

2.8 修改jumpserver配置文件
$ cd /opt/jumpserver
$ cp config_example.py config.py
$ vi config.py# 我們計劃修改 DevelopmentConfig中的配置,因爲默認jumpserver是使用該配
class DevelopmentConfig(Config):
DEBUG = True
DISPLAY_PER_PAGE = 20
DB_ENGINE = 'mysql'
DB_HOST = '127.0.0.1'
DB_PORT = 3306
DB_USER = 'jumpserver'
DB_PASSWORD = 'longtel.com'
DB_NAME = 'jumpserver'
EMAIL_HOST = 'smtp.exmail.qq.com'
EMAIL_PORT = 465
EMAIL_HOST_USER = '[email protected]'
EMAIL_HOST_PASSWORD = 'longtel.com'
EMAIL_USE_SSL = True
EMAIL_USE_TLS = False
EMAIL_SUBJECT_PREFIX = '[Jumpserver] '
SITE_URL = 'http://192.168.94.91:8080'


2.9 生成數據庫表結構和初始化數據
$ cd /opt/jumpserver/utils
$ sh make_migrations.sh
$ sh init_db.sh

2.10 運行Jumpserver
$ cd /opt/jumpserver
$ python run_server.py
運行不報錯,請瀏覽器訪問 http://192.168.1.76:8080/ 賬號: admin 密碼: admin
三. 安裝 SSH Server: Coco
3.1 下載clone項目
新開一個終端,連接測試機
$ source /opt/py3/bin/activate
$ cd /opt
$ git clone https://github.com/jumpserver/coco.git

3.2 安裝依賴
$ cd /opt/coco/requirements
$ yum -y install $(cat rpm_requirements.txt)
$ pip install -r requirements.txt

3.3 查看配置文件並運行
$ cd /opt/coco
$ cat config.py
$ python run_server.py
ERROR:root:Load access key failedUsing access key 311d0e77-5ec9-4c46-a131-7409e1daf271:***WARNING:/opt/coco/coco/service.py:App auth failed, Access key error or need admin active it
這時需要去 jumpserver管理後臺-應用程序-終端(http://192.168.1.76:8080/applications/terminal/)接受coco的註冊,並填寫如下信息:

Coco version 0.4.0, more see https://www.jumpserver.orgStarting ssh server at 0.0.0.0:2222Quit the server with CONTROL-C.
這時完成安裝
3.4 測試連接
$ ssh -p2222 [email protected]密碼: admin
如果是用Xshell登錄語法如下
$ssh [email protected] 2222密碼: admin如果能登陸代表部署成功
四. 安裝 Web Terminal: Luna
新開一個終端,連接測試機
4.1 下載clone項目
$source /opt/py3/bin/activate
$ cd /opt
$ git clone https://github.com/jumpserver/luna.git

4.2 安裝依賴
$ cd /opt/luna/requirements
$ yum -y install $(cat rpm_requirements.txt)
$ pip install -r requirements.txt

4.3 查看配置文件並運行
$ cd /opt/luna
$ cat config.py
$ python run_server.py
ERROR:root:Load access key failedUsing access key 5bfdbf63-bef5-4cfb-9e31-2d873bdddb03:***WARNING:luna.service:App auth failed, Access key error or need admin active it

4.4 同樣去jumpserver管理後臺接受luna註冊
應用程序-終端 接受,並填寫如下信息

4.5 測試
應用程序-終端-luna-點擊連接 或者 直接訪問 http://192.168.1.76:5000

五.jumpserver 使用參考官網:
https://github.com/jumpserver/jumpserver/wiki/v0.4.0-%E5%BA%94%E7%94%A8%E5%9B%BE%E8%A7%A3
文章來源:https://github.com/jumpserver/jumpserver/wiki/v0.4.0-%E5%9F%BA%E4%BA%8E-CenOS7-%E7%9A%84%E7%B3%BB%E7%BB%9F
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章