阿里雲ECS安裝 jumpserver1.5.2
阿里雲ECShtml
公網IP :47.98.237.233前端
內網IP:172.16.100.255java
在「安全組」 開通ECS的相關端口python
一. 準備 Python3 和 Python 虛擬環境
yum -y install wget sqlite-devel xz gcc automake zlib-devel openssl-devel epel-release git 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
cd /opt python3 -m venv py3 source /opt/py3/bin/activate # 看到下面的提示符表明成功,之後運行 Jumpserver 都要先運行以上 source 命令,如下全部命令均在該虛擬環境中運行 (py3) [root@localhost py3]
二. 安裝 Jumpserver 1.5.2
2.1 下載或 Clone 項目mysql
項目提交較多 git clone 時較大,你能夠選擇去 Github 項目頁面直接下載zip包,我是下載安裝包以後安裝linux
cd /opt/ #git clone --depth=1 https://github.com/jumpserver/jumpserver.git && cd jumpserver && git checkout master (從官網下載直接安裝) 下載安裝包以後把下載的jumpserver-master.zip上傳到 /opt目錄 unzip jumpserver-master.zip mv jumpserver-master jumpserver
2.2 安裝依賴 RPM 包 cd /opt/jumpserver/requirements yum -y install $(cat rpm_requirements.txt) # 若是沒有任何報錯請繼續,報錯多測試幾回
2.3 安裝 Python 庫依賴nginx
pip install -r requirements.txt # 不要指定-i參數,由於鏡像上可能沒有最新的包,若是沒有任何報錯請繼續,報錯多測試幾回
2.4 安裝 Redis, Jumpserver 使用 Redis 作 cachegit
yum -y install redis
systemctl start redis
systemctl enable redis
2.5 安裝 MySQLgithub
yum -y install mariadb mariadb-devel mariadb-server # centos7下安裝的是mariadb
systemctl start mariadb
systemctl enable mariadb
2.6 建立數據庫 Jumpserver 並受權web
$ mysql > create database jumpserver default charset 'utf8'; > grant all on jumpserver.* to 'jumpserver'@'127.0.0.1' identified by 'jason_zhang'; > FLUSH PRIVILEGES;
2.7 修改 Jumpserver 配置文件
$ cd /opt/jumpserver $ cp config_example.yml config.yml $ SECRET_KEY=`cat /dev/urandom | tr -dc A-Za-z0-9 | head -c 50` # 生成隨機SECRET_KEY $ echo "SECRET_KEY=$SECRET_KEY" >> ~/.bashrc $ BOOTSTRAP_TOKEN=`cat /dev/urandom | tr -dc A-Za-z0-9 | head -c 16` # 生成隨機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" $ echo -e "\033[31m 你的BOOTSTRAP_TOKEN是 $BOOTSTRAP_TOKEN \033[0m"
vim 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: dHMiHPFasObnAMEbYZZGgQKKErUDA1zA0Td0zf4Kt0qIMLb # SECURITY WARNING: keep the bootstrap token used in production secret! # 預共享Token coco和guacamole用來註冊服務帳號,不在使用原來的註冊接受機制 BOOTSTRAP_TOKEN: lajd6483fue6Z # 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: jason_zhang DB_NAME: jumpserver # When Django start it will bind this host and port # ./manage.py runserver 127.0.0.1:8080 # 運行時綁定端口 HTTP_BIND_HOST: 127.0.0.1 HTTP_LISTEN_PORT: 8080 # Use Redis as broker for celery and web socket # Redis配置 REDIS_HOST: 127.0.0.1 # When Django start it will bind this host and port # ./manage.py runserver 127.0.0.1:8080 # 運行時綁定端口 HTTP_BIND_HOST: 127.0.0.1 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 來進行認證設置 # 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: False # # Use Radius authorization # 使用Radius來認證 # AUTH_RADIUS: false # RADIUS_SERVER: localhost # RADIUS_PORT: 1812 # RADIUS_SECRET: # OTP settings # OTP/MFA 配置 # OTP_VALID_WINDOW: 0 # OTP_ISSUER_NAME: Jumpserver
2.8 生成數據庫表結構和初始化數據
cd /opt/jumpserver/utils
bash make_migrations.sh
啓動jumpserver
$ cd /opt/jumpserver $ ./jms start all -d # 後臺運行使用 -d 參數./jms start all -d # 新版本更新了運行腳本, 使用方式./jms start|stop|status all 後臺運行請添加 -d 參數
運行不報錯, 請繼續往下操做
三. 安裝 SSH Server 和 WebSocket Server: Coco
新開一個終端,運行Python3虛擬環境
source /opt/py3/bin/activate
3.1 下載或 Clone 項目
cd /opt git clone https://github.com/jumpserver/coco.git && cd coco && git checkout master
3.2 安裝依賴
cd /opt/coco/requirements yum -y install $(cat rpm_requirements.txt) pip install -r requirements.txt # 若是下載速度很慢, 能夠換國內源 $ pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/
3.3 查看配置文件並運行
$ 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
# 項目名稱, 會用來向Jumpserver註冊, 識別而已, 不能重複 # NAME: {{ Hostname }} # Jumpserver項目的url, api請求註冊會使用 CORE_HOST: http://127.0.0.1:8080 # Bootstrap Token, 預共享祕鑰, 用來註冊coco使用的service account和terminal # 請和jumpserver 配置文件中保持一致,註冊完成後能夠刪除 BOOTSTRAP_TOKEN: lajd6485d73**** # 啓動時綁定的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 # 加密密鑰 # SECRET_KEY: null # 設置日誌級別 [DEBUG, INFO, WARN, ERROR, FATAL, CRITICAL] LOG_LEVEL: ERROR # 日誌存放的目錄 # LOG_DIR: logs # SSH白名單 # ALLOW_SSH_USER: all # SSH黑名單, 若是用戶同時在白名單和黑名單,黑名單優先生效 # BLOCK_SSH_USER: # - # 和Jumpserver 保持心跳時間間隔 # HEARTBEAT_INTERVAL: 5 # Admin的名字,出問題會提示給用戶 # ADMINS: '' # 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
啓動cocod
$ ./cocod start -d # 後臺運行使用 -d 參數./cocod start -d
# 新版本更新了運行腳本, 使用方式./cocod start|stop|status 後臺運行請添加 -d 參數
四. 安裝 Web Terminal 前端: Luna
另開一個終端,運行Python3虛擬環境
Luna 已改成純前端,須要 Nginx 來運行訪問
訪問(https://github.com/jumpserver/luna/releases)下載對應版本的 release 包,放在/opt目錄下,直接解壓,不須要編譯
4.1 解壓 Luna
tar xvf luna.tar.gz
五. 安裝 Windows 支持組件(若是不須要管理 windows 資產, 能夠直接跳過這一步)
5.1 安裝依賴
$ 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
5.2 編譯安裝 guacamole 服務
$ cd /opt
$ git clone --depth=1 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 $ ln -s /usr/local/lib/freerdp/*.so /usr/lib64/freerdp/ $ cd .. $ rm -rf guacamole-server-0.9.14 $ ldconfig
5.3 配置 Tomcat
$ mkdir -p /config/guacamole /config/guacamole/lib /config/guacamole/extensions # 建立 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://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-8/v8.5.40/bin/apache-tomcat-8.5.40.tar.gz $ tar xf apache-tomcat-8.5.40.tar.gz $ rm -rf apache-tomcat-8.5.40.tar.gz $ mv apache-tomcat-8.5.40 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 # 修改默認端口爲 8081 $ sed -i 's/FINE/WARNING/g' /config/tomcat8/conf/logging.properties # 修改 log 等級爲 WARNING $ cd /config $ wget https://github.com/ibuler/ssh-forward/releases/download/v0.0.5/linux-amd64.tar.gz # 若是網絡有問題致使下載沒法完成可使用下面地址 $ wget https://demo.jumpserver.org/download/ssh-forward/v0.0.5/linux-amd64.tar.gz $ tar xf linux-amd64.tar.gz -C /bin/ $ chmod +x /bin/ssh-forward
5.4 配置環境變量
# 勿屢次執行如下環境設置
$ 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
5.5 啓動 Guacamole
$ /etc/init.d/guacd start
$ sh /config/tomcat8/bin/startup.sh
六. 配置 Nginx 整合各組件
6.1 安裝 Nginx
$ yum install yum-utils
$ 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
$ yum makecache fast $ yum install -y nginx $ rm -rf /etc/nginx/conf.d/default.conf $ systemctl enable nginx
6.3 準備配置文件 修改 /etc/nginx/conf.d/jumpserver.conf
先刪掉默認的配置文件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 /socket.io/ { proxy_pass http://localhost:5000/socket.io/; 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/; 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; client_max_body_size 10000m; ##windows資產上傳文件大小限制 } 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; } }
6.3 運行 Nginx
nginx -t # 確保配置沒有問題, 有問題請先解決
systemctl start nginx systemctl enable nginx
6.4 開始使用 Jumpserver
檢查應用是否已經正常運行
服務所有啓動後, 訪問 http://47.98.237.233, 訪問nginx代理的端口, 不要再經過8080端口訪問
默認帳號: admin 密碼: admin
到Jumpserver 會話管理-終端管理 檢查 Coco Guacamole 等應用的註冊。
測試鏈接
若是登陸客戶端是 macOS 或 Linux, 登陸語法以下
$ ssh -p2222 admin@192.168.244.144
$ sftp -P2222 admin@192.168.244.144
密碼: admin
若是登陸客戶端是 Windows, Xshell Terminal 登陸語法以下
$ ssh admin@192.168.244.144 2222
$ sftp admin@192.168.244.144 2222 密碼: admin 若是能登錄表明部署成功 # sftp默認上傳的位置在資產的 /tmp 目錄下 # windows拖拽上傳的位置在資產的 Guacamole RDP上的 G 目錄下
七.開機自啓動
Jumpserver自啓動
vim /usr/lib/systemd/system/jms.service
[Unit] Description=jms After=network.target mariadb.service redis.service Wants=mariadb.service redis.service [Service] Type=forking Environment="PATH=/opt/py3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin" ExecStart=/opt/jumpserver/jms start all -d ExecReload= ExecStop=/opt/jumpserver/jms stop [Install] WantedBy=multi-user.target
Coco自啓動
vim /usr/lib/systemd/system/coco.service
[Unit] Description=coco After=network.target jms.service [Service] Type=forking PIDFile=/opt/coco/coco.pid Environment="PATH=/opt/py3/bin" ExecStart=/opt/coco/cocod start -d ExecReload= ExecStop=/opt/coco/cocod stop [Install] WantedBy=multi-user.target
Guacamole自啓動
chkconfig guacd on
vim /usr/lib/systemd/system/guacamole.service
[Unit] Description=guacamole After=network.target jms.service Wants=jms.service [Service] Type=forking # PIDFile=/config/tomcat8/tomcat.pid # BOOTSTRAP_TOKEN 根據實際狀況修改 Environment="JUMPSERVER_SERVER=http://127.0.0.1:8080" "JUMPSERVER_KEY_DIR=/config/guacamole/keys" "GUACAMOLE_HOME=/config/guacamole" "BOOTSTRAP_TOKEN=lajd6485d73fue***" ExecStart=/config/tomcat8/bin/startup.sh ExecReload= ExecStop=/config/tomcat8/bin/shutdown.sh [Install] WantedBy=multi-user.target
# 開機自啓設置 systemctl enable jms systemctl enable coco systemctl enable guacamole # 啓動 systemctl start jms systemctl start coco systemctl start guacamole # 中止 systemctl stop jms systemctl stop coco systemctl stop guacamole
Windows 沒法鏈接的問題及解決
a)若是白屏 多是nginx配置文件的guacamole設置的不對,也可能運行guacamole的docker容器有問題,總之請求到不了guacamole
b)若是顯示沒有權限 多是你在 終端管理裏沒有接受 guacamole的註冊,請接受一下,若是仍是不行,就刪除剛纔的註冊,重啓guacamole的docker從新註冊
c)若是顯示未知問題 多是你的資產填寫的端口不對,或者受權的系統用戶的協議不是rdp
d)提示沒法鏈接服務器,請聯繫管理員或查看日誌 通常狀況下是登陸的系統帳戶不正確,能夠從Windows的日誌查看信息
e)提示網絡問題沒法鏈接或者超時,請檢查網絡鏈接並重試,或聯繫管理員 通常狀況下是防火牆設置不正確,能夠從Windows的日誌查看信息
https://jumpserver.readthedocs.io/zh/master/faq_rdp.html
https://www.cnblogs.com/kevingrace/p/5950472.html
查看guacamole的註冊註冊狀態,若是不在線或者顯示在線也這樣,刪掉從新註冊一次就行了了
yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum makecache fast
rpm --import https://mirrors.aliyun.com/docker-ce/linux/centos/gpg
yum -y install docker-ce
systemctl enable docker
curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://f1361db2.m.daocloud.io
systemctl restart docker
docker run --name jms_guacamole --restart=always -d -p 8081:8081 -e JUMPSERVER_SERVER=http://172.16.100.234:8080 -e BOOTSTRAP_TOKEN=ZMs5OmkjYJ8H5V2W jumpserver/jms_guacamole:1.4.8