1.介紹
Jumpserver是一款由python編寫開源的跳板機(堡壘機)系統,實現了跳板機應有的功能。基於ssh協議來管理,客戶端無需安裝agent。 特點: 完全開源,GPL授權 Python編寫,支持再次開發 實現了跳板機基本功能,認證、授權、審計 集成了Ansible。
2.優點
1、完全開源,也可以選擇商業支持; 2、支持多種常用的操作系統; 3、提供用戶會話記錄功能,可以手動終端不明的會話記錄; 4、支持錄像回放功能,方便生產事故后的問題追溯; 5、所有密碼通過系統管理,最終用戶不需知道服務器的密碼。終結了生產環境密碼手工拷貝和傳播的方式。
3.安裝部署
3.1環境准備
關閉防火牆和SELinux
服務器 | 作用 |
---|---|
jumpserver | 10.0.0.123 |
client | 10.0.0.124 |
3.2更新源
yum install git wegt -y wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo yum makecach yum updata -y
3.3安裝依賴包
yum -y install epel-release
3.4. 安裝 Python3.6 MySQL Redis
yum install -y python36 python36-devel redis mariadb-server mariadb-devel mariadb
3.5啟動服務
systemctl start mariadb redis
systemctl enable mariadb redis
3.6進入數據庫並創建jumpserver庫
mysql -uroot create database jumpserver default charset 'utf8' collate 'utf8_bin'; grant all on jumpserver.* to 'jumpserver'@'10.0.0.%' identified by 'weakPassword'; flush privileges;
python3.6 -m venv /opt/py3
3.8載入 Python 虛擬環境
source /opt/py3/bin/activate
cd /opt && \ wget https://github.com/jumpserver/jumpserver/releases/download/v2.3.1/jumpserver-v2.3.1.tar.gz tar xf jumpserver-v2.3.1.tar.gz mv jumpserver-v2.3.1 jumpserver
cd /opt/jumpserver/requirements yum install -y $(cat rpm_requirements.txt) pip install wheel && \ pip install --upgrade pip setuptools && \ pip install -r requirements.txt ################################# 國內源,如果服務啟動不成功用國內源 pip install wheel -i https://mirrors.aliyun.com/pypi/simple/ pip install --upgrade pip setuptools -i https://mirrors.aliyun.com/pypi/simple/ pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/
ps:確保已經載入 py3 虛擬環境, 中間如果遇到報錯一般是依賴包沒裝全, 可以通過 搜索引擎 解決
pip install wheel -i https://mirrors.aliyun.com/pypi/simple/ pip install --upgrade pip setuptools -i https://mirrors.aliyun.com/pypi/simple/ pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/
4.1修改配置文件
cd /opt/jumpserver && \ cp config_example.yml config.yml && \ vi config.yml
# SECURITY WARNING: keep the secret key used in production secret! # 加密秘鑰 生產環境中請修改為隨機字符串,請勿外泄, 可使用命令生成 # cat /dev/urandom | tr -dc A-Za-z0-9 | head -c 49;echo SECRET_KEY:aumutGWrDOKyOwY0w22Pjg4c4RCZISjUjQAd3CB2oK7dZ7J4Bu #50位 # SECURITY WARNING: keep the bootstrap token used in production secret! # 預共享Token coco和guacamole用來注冊服務賬號,不在使用原來的注冊接受機制 BOOTSTRAP_TOKEN:KN9X8hHaWuNFQ5gTdjDK #20位 # Development env open this, when error occur display the full process track, Production disable it # DEBUG 模式 開啟DEBUG后遇到錯誤時可以看到更多日志 DEBUG: false # DEBUG, INFO, WARNING, ERROR, CRITICAL can set. See https://docs.djangoproject.com/en/1.10/topics/logging/ # 日志級別 LOG_LEVEL: ERROR # LOG_DIR: # Session expiration setting, Default 24 hour, Also set expired on on browser close # 瀏覽器Session過期時間,默認24小時, 也可以設置瀏覽器關閉則過期 # SESSION_COOKIE_AGE: 86400 SESSION_EXPIRE_AT_BROWSER_CLOSE: true # Database setting, Support sqlite3, mysql, postgres .... # 數據庫設置 # See https://docs.djangoproject.com/en/1.10/ref/settings/#databases # SQLite setting: # 使用單文件sqlite數據庫 # DB_ENGINE: sqlite3 # DB_NAME: # MySQL or postgres setting like: # 使用Mysql作為數據庫 DB_ENGINE: mysql DB_HOST: 127.0.0.1 DB_PORT: 3306 DB_USER: jumpserver DB_PASSWORD: weakPassword DB_NAME: jumpserver # When Django start it will bind this host and port # ./manage.py runserver 127.0.0.1:8080 # 運行時綁定端口 HTTP_BIND_HOST: 0.0.0.0 HTTP_LISTEN_PORT: 8080 WS_LISTEN_PORT: 8070 # Use Redis as broker for celery and web socket # Redis配置 REDIS_HOST: 127.0.0.1 REDIS_PORT: 6379 REDIS_PASSWORD: ZhYnLrodpmPncovxJTnRyiBs # REDIS_DB_CELERY: 3 # REDIS_DB_CACHE: 4 # Use OpenID authorization # 使用OpenID 來進行認證設置 # 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 # AUTH_OPENID_IGNORE_SSL_VERIFICATION: True # AUTH_OPENID_SHARE_SESSION: True # Use Radius authorization # 使用Radius來認證 # AUTH_RADIUS: false # RADIUS_SERVER: localhost # RADIUS_PORT: 1812 # RADIUS_SECRET: # CAS 配置 # AUTH_CAS': False, # CAS_SERVER_URL': "http://host/cas/", # CAS_ROOT_PROXIED_AS': 'http://jumpserver-host:port', # CAS_LOGOUT_COMPLETELY': True, # CAS_VERSION': 3, # LDAP/AD settings # LDAP 搜索分頁數量 # AUTH_LDAP_SEARCH_PAGED_SIZE: 1000 # # 定時同步用戶 # 啟用 / 禁用 # AUTH_LDAP_SYNC_IS_PERIODIC: True # 同步間隔 (單位: 時) (優先) # AUTH_LDAP_SYNC_INTERVAL: 12 # Crontab 表達式 # AUTH_LDAP_SYNC_CRONTAB: * 6 * * * # # LDAP 用戶登錄時僅允許在用戶列表中的用戶執行 LDAP Server 認證 # AUTH_LDAP_USER_LOGIN_ONLY_IN_USERS: False # # LDAP 認證時如果日志中出現以下信息將參數設置為 0 (詳情參見:https://www.python-ldap.org/en/latest/faq.html) # In order to perform this operation a successful bind must be completed on the connection # AUTH_LDAP_OPTIONS_OPT_REFERRALS: -1 # OTP settings # OTP/MFA 配置 # OTP_VALID_WINDOW: 0 # OTP_ISSUER_NAME: Jumpserver # Perm show single asset to ungrouped node # 是否把未授權節點資產放入到 未分組 節點中 # PERM_SINGLE_ASSET_TO_UNGROUP_NODE: false # # 啟用定時任務 # PERIOD_TASK_ENABLE: True # # 啟用二次復合認證配置 # LOGIN_CONFIRM_ENABLE: False # # Windows 登錄跳過手動輸入密碼 WINDOWS_SKIP_ALL_MANUAL_PASSWORD: True
cd /opt/jumpserver
./jms start -d
4.3部署 KoKo 組件
cd /opt && \ wget https://github.com/jumpserver/koko/releases/download/v2.3.1/koko-v2.3.1-linux-amd64.tar.gz tar -xf koko-v2.3.1-linux-amd64.tar.gz mv koko-v2.3.1-linux-amd64 koko chown -R root:root koko cd koko mv kubectl /usr/local/bin/ wget https://download.jumpserver.org/public/kubectl.tar.gz tar -xf kubectl.tar.gz chmod 755 kubectl mv kubectl /usr/local/bin/rawkubectl rm -rf kubectl.tar.gz cp config_example.yml config.yml vi config.yml
# 項目名稱, 會用來向Jumpserver注冊, 識別而已, 不能重復 # NAME: {{ Hostname }} # Jumpserver項目的url, api請求注冊會使用 CORE_HOST: http://127.0.0.1:8080 # Bootstrap Token, 預共享秘鑰, 用來注冊coco使用的service account和terminal BOOTSTRAP_TOKEN: KN9X8hHaWuNFQ5gTdjDK ####和**/opt/jumpserver/config.yml對應** # 請和jumpserver 配置文件中保持一致,注冊完成后可以刪除 # 啟動時綁定的ip, 默認 0.0.0.0 # BIND_HOST: 0.0.0.0 # 監聽的SSH端口號, 默認2222 # SSHD_PORT: 2222 # 監聽的HTTP/WS端口號,默認5000 # HTTPD_PORT: 5000 # 項目使用的ACCESS KEY, 默認會注冊,並保存到 ACCESS_KEY_STORE中, # 如果有需求, 可以寫到配置文件中, 格式 access_key_id:access_key_secret # ACCESS_KEY: null # ACCESS KEY 保存的地址, 默認注冊后會保存到該文件中 # ACCESS_KEY_FILE: data/keys/.access_key # 設置日志級別 [DEBUG, INFO, WARN, ERROR, FATAL, CRITICAL] LOG_LEVEL: ERROR ####和/opt/jumpserver/config.yml對應 # SSH連接超時時間 (default 15 seconds) # SSH_TIMEOUT: 15 # 語言 [en,zh] # LANGUAGE_CODE: zh # SFTP的根目錄, 可選 /tmp, Home其他自定義目錄 # SFTP_ROOT: /tmp # SFTP是否顯示隱藏文件 # SFTP_SHOW_HIDDEN_FILE: false # 是否復用和用戶后端資產已建立的連接(用戶不會復用其他用戶的連接) # REUSE_CONNECTION: true # 資產加載策略, 可根據資產規模自行調整. 默認異步加載資產, 異步搜索分頁; 如果為all, 則資產全部加載, 本地搜索分頁. # ASSET_LOAD_POLICY: # zip壓縮的最大額度 (單位: M) # ZIP_MAX_SIZE: 1024M # zip壓縮存放的臨時目錄 /tmp # ZIP_TMP_PATH: /tmp # 向 SSH Client 連接發送心跳的時間間隔 (單位: 秒),默認為30, 0則表示不發送 # CLIENT_ALIVE_INTERVAL: 30 # 向資產發送心跳包的重試次數,默認為3 # RETRY_ALIVE_COUNT_MAX: 3 # 會話共享使用的類型 [local, redis], 默認local # SHARE_ROOM_TYPE: local # Redis配置 # REDIS_HOST: 127.0.0.1 # REDIS_PORT: 6379 # REDIS_PASSWORD: # REDIS_CLUSTERS: # REDIS_DB_ROOM:
./koko -d后台運行
cd /opt && \ wget -O docker-guacamole-v2.3.1.tar.gz https://github.com/jumpserver/docker-guacamole/archive/master.tar.gz mkdir /opt/docker-guacamole && \ tar -xf docker-guacamole-v2.3.1.tar.gz -C /opt/docker-guacamole --strip-components 1 && \ rm -rf /opt/docker-guacamole-v2.3.1.tar.gz && \ cd /opt/docker-guacamole && \ wget http://download.jumpserver.org/public/guacamole-server-1.2.0.tar.gz && \ tar -xf guacamole-server-1.2.0.tar.gz && \ wget http://download.jumpserver.org/public/ssh-forward.tar.gz && \ tar -xf ssh-forward.tar.gz -C /bin/ && \ chmod +x /bin/ssh-forward cd /opt/docker-guacamole/guacamole-server-1.2.0
yum install cairo-devel libjpeg-turbo-devel libpng-devel uuid-devel ffmpeg-devel freerdp-devel pango-devel libssh2-devel libtelnet-devel libvncserver-devel libwebsockets-devel pulseaudio-libs-devel openssl-devel libvorbis-devel libwebp-devel -y
./configure --with-init-dir=/etc/init.d && \ make && \ make install
yum install -y java-1.8.0-openjdk mkdir -p /config/guacamole /config/guacamole/extensions /config/guacamole/record /config/guacamole/drive && \ chown daemon:daemon /config/guacamole/record /config/guacamole/drive && \ cd /config
wget http://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-9/v9.0.38/bin/apache-tomcat-9.0.38.tar.gz tar -xf apache-tomcat-9.0.38.tar.gz mv apache-tomcat-9.0.38 tomcat9 rm -rf /config/tomcat9/webapps/* sed -i 's/Connector port="8080"/Connector port="8081"/g' /config/tomcat9/conf/server.xml echo "java.util.logging.ConsoleHandler.encoding = UTF-8" >> /config/tomcat9/conf/logging.properties wget http://download.jumpserver.org/release/v2.3.1/guacamole-client-v2.3.1.tar.gz tar -xf guacamole-client-v2.3.1.tar.gz rm -rf guacamole-client-v2.3.1.tar.gz cp guacamole-client-v2.3.1/guacamole-*.war /config/tomcat9/webapps/ROOT.war cp guacamole-client-v2.3.1/guacamole-*.jar /config/guacamole/extensions/ mv /opt/docker-guacamole/guacamole.properties /config/guacamole/ rm -rf /opt/docker-guacamole
export JUMPSERVER_SERVER=http://127.0.0.1:8080 echo "export JUMPSERVER_SERVER=http://127.0.0.1:8080" >> ~/.bashrc export BOOTSTRAP_TOKEN=KN9X8hHaWuNFQ5gTdjDK #對應jumpserver/config.yml 文件 echo "export BOOTSTRAP_TOKEN=KN9X8hHaWuNFQ5gTdjDK" >> ~/.bashrc #對應jumpserver/config.yml 文件 export JUMPSERVER_KEY_DIR=/config/guacamole/data/keys echo "export JUMPSERVER_KEY_DIR=/config/guacamole/data/keys" >> ~/.bashrc export GUACAMOLE_HOME=/config/guacamole echo "export GUACAMOLE_HOME=/config/guacamole" >> ~/.bashrc export GUACAMOLE_LOG_LEVEL=ERROR echo "export GUACAMOLE_LOG_LEVEL=ERROR" >> ~/.bashrc export JUMPSERVER_ENABLE_DRIVE=true echo "export JUMPSERVER_ENABLE_DRIVE=true" >> ~/.bashrc
/etc/init.d/guacd start sh /config/tomcat9/bin/startup.sh
ps:環境變量說明
JUMPSERVER_SERVER 指 core 訪問地址 BOOTSTRAP_TOKEN 為 Jumpserver/config.yml 里面的 BOOTSTRAP_TOKEN 值 JUMPSERVER_KEY_DIR 認證成功后 key 存放目錄 GUACAMOLE_HOME 為 guacamole.properties 配置文件所在目錄 GUACAMOLE_LOG_LEVEL 為生成日志的等級 JUMPSERVER_ENABLE_DRIVE 為 rdp 協議掛載共享盤
cd /opt wget https://github.com/jumpserver/lina/releases/download/v2.3.1/lina-v2.3.1.tar.gz tar -xf lina-v2.3.1.tar.gz mv lina-v2.3.1 lina useradd nginx -M -s/sbin/nologin chown -R nginx:nginx lina
cd /opt wget https://github.com/jumpserver/luna/releases/download/v2.3.1/luna-v2.3.1.tar.gz tar -xf luna-v2.3.1.tar.gz mv luna-v2.3.1 luna chown -R nginx:nginx luna
vim /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 module_hotfixes=true yum install nginx -y echo > /etc/nginx/conf.d/default.conf vi /etc/nginx/conf.d/jumpserver.conf
server { listen 80; client_max_body_size 100m; # 錄像及文件上傳大小限制 location /ui/ { try_files $uri / /index.html; alias /opt/lina/; } 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 /api/ { 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; } location /core/ { 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; } location / { rewrite ^/(.*)$ /ui/$1 last; } }
nginx -t
systemctl start nginx