Jumpserver安裝及使用


一、jumpserver簡介

JumpServer 是全球首款完全開源的堡壘機, 使用 GNU GPL v2.0 開源協議, 是符合 4A 的專業運維審計系統。

JumpServer 使用 Python / Django 進行開發, 遵循 Web 2.0 規范, 配備了業界領先的 Web Terminal 解決方案, 交互界面美觀、用戶體驗好。

JumpServer 采納分布式架構, 支持多機房跨區域部署, 中心節點提供 API, 各機房部署登錄節點, 可橫向擴展、無並發訪問限制。

JumpServer 現已支持管理 SSH、 Telnet、 RDP、 VNC 協議資產。

官網:https://docs.jumpserver.org/zh/master/

二、jumpserver安裝

2.1、極速安裝

采用極速安裝的方式

https://docs.jumpserver.org/zh/master/install/setup_by_fast/

[root@cloud01 ~]# curl -sSL https://github.com/jumpserver/jumpserver/releases/download/v2.1.1/quick_start.sh
#!/bin/bash
#

which wget >/dev/null 2>&1
if [ $? -ne 0 ];then
    yum install -y wget
fi

which git >/dev/null 2>&1
    if [ $? -ne 0 ];then
        yum install -y git
    fi

if [ ! -d "/opt/setuptools" ]; then
    wget -qO /opt/setuptools.tar.gz http://demo.jumpserver.org/download/setuptools.tar.gz
    tar -xf /opt/setuptools.tar.gz -C /opt
    rm -rf /opt/setuptools.tar.gz
fi

cd /opt/setuptools
git pull

if [ ! -f "/opt/setuptools/config.conf" ]; then
    cp config_example.conf config.conf
fi

./jmsctl.sh install
[root@cloud01 ~]# curl -sSL https://github.com/jumpserver/jumpserver/releases/download/v2.1.1/quick_start.sh | sh

image

可以通過http://ip:port訪問

image

2.2、修改密碼

image

image

2.3、相關命令

jumpserver默認安裝在/opt目錄下

[root@cloud01 opt]# ls
containerd  jumpserver  lina  luna  py3  setuptools
[root@cloud01 opt]# cd setuptools/
[root@cloud01 setuptools]# ll
total 44
-rw-r--r-- 1 root root   989 Aug 11 11:49 config.conf
-rw-r--r-- 1 root root   875 Aug  9 15:07 config_example.conf
-rwxr-xr-x 1 root root  1961 Aug  9 15:07 jmsctl.sh
-rw-r--r-- 1 root root 18046 Aug  9 15:07 LICENSE
-rw-r--r-- 1 root root   623 Aug  9 15:07 README.md
drwxr-xr-x 6 root root  4096 Aug  9 15:07 scripts
drwxr-xr-x 2 root root  4096 Aug 11 11:46 v2.1.1
[root@cloud01 setuptools]# tree
.
├── config.conf
├── config_example.conf
├── jmsctl.sh
├── LICENSE
├── README.md
├── scripts
│   ├── check_install_env.sh
│   ├── docker
│   │   └── daemon.json
│   ├── install_core.sh
│   ├── install_docker.sh
│   ├── install_guacamole.sh
│   ├── install_koko.sh
│   ├── install_mariadb.sh
│   ├── install_nginx.sh
│   ├── install_py3.sh
│   ├── install_redis.sh
│   ├── install.sh
│   ├── install_status.sh
│   ├── nginx
│   │   ├── jumpserver.conf
│   │   ├── nginx-1.18.0-1.el7.ngx.x86_64.rpm
│   │   └── nginx.repo
│   ├── pypi
│   │   └── pip.conf
│   ├── reset.sh
│   ├── service
│   │   └── jms_core.service
│   ├── set_firewall.sh
│   ├── start.sh
│   ├── stop.sh
│   ├── uninstall.sh
│   └── upgrade.sh
└── v2.1.1
    ├── jumpserver-v2.1.1.tar.gz
    ├── lina-v2.1.1.tar.gz
    └── luna-v2.1.1.tar.gz

6 directories, 31 files
[root@cloud01 setuptools]# cat jmsctl.sh #啟停腳本
#!/usr/bin/env bash
#

BASE_DIR=$(cd "$(dirname "$0")";pwd)
PROJECT_DIR=${BASE_DIR}
SCRIPT_DIR=${BASE_DIR}/scripts
action=$1
target=$2

if [ ! -f "$PROJECT_DIR/config.conf" ]; then
    echo -e "Error: No config file found."
    echo -e "You can run 'cp config_example.conf config.conf', and edit it."
    exit 1
fi

source ${PROJECT_DIR}/config.conf

function usage() {
   echo "JumpServer 部署安裝腳本"
   echo
   echo "Usage: "
   echo "  jmsctl [COMMAND] ..."
   echo "  jmsctl --help"
   echo
   echo "Commands: "
   echo "  install      安裝 JumpServer"
   echo "  start        啟動 JumpServer"
   echo "  stop         停止 JumpServer"
   echo "  restart      重啟 JumpServer"
   echo "  status       檢查 JumpServer"
   echo "  uninstall    卸載 JumpServer"
   echo "  upgrade      升級 JumpServer"
   echo "  reset        重置組件"
}

function main() {
   case "${action}" in
      install)
         bash ${SCRIPT_DIR}/install.sh
         ;;
      uninstall)
         bash ${SCRIPT_DIR}/uninstall.sh
         ;;
      upgrade)
         bash ${SCRIPT_DIR}/upgrade.sh
         ;;
      start)
         bash ${SCRIPT_DIR}/start.sh
         ;;
      stop)
         bash ${SCRIPT_DIR}/stop.sh
         ;;
      restart)
         bash ${SCRIPT_DIR}/stop.sh
         bash ${SCRIPT_DIR}/start.sh
         ;;
      status)
         bash ${SCRIPT_DIR}/install_status.sh
         ;;
      reset)
         if [ ! $target ]; then
             echo -e "Usage: jmsctl reset COMMAND\n"
             echo -e "Commands:"
             echo -e "  koko         重置 koko"
             echo -e "  guacamole    重置 guacamole"
             exit 1
         else
             bash ${SCRIPT_DIR}/reset.sh $target
         fi
         ;;
      --help)
         usage
         ;;
      -h)
         usage
         ;;
      *)
         echo -e "jmsctl: unknown COMMAND: '$action'"
         echo -e "See 'jmsctl --help' \n"
         usage
    esac
}

main

#配置文件
[root@cloud01 setuptools]# cat config.conf 
# 以下設置默認情況下不需要修改, 系統會自動生成隨機字符串填入

# 需要安裝的版本
Version=v2.1.1

# Jms 加密配置
SECRET_KEY=Hak96I6o80uvcN7JhziR1OE6zpPrtBUfYJFXlE0THCy9kG0mZT
BOOTSTRAP_TOKEN=D8yzPUwX3z9PrLcf

# 數據庫 配置, 如果 數據庫 安裝在其他的服務器, 請修改下面設置
DB_HOST=127.0.0.1
DB_PORT=3306
DB_USER=jumpserver
DB_PASSWORD=pnWq6QqkbIyFuSuF1rwU5
DB_NAME=jumpserver

# Redis 配置, 如果 Redis 安裝在其他的服務器, 請修改下面設置
REDIS_HOST=127.0.0.1
REDIS_PORT=6379
REDIS_PASSWORD=uvfIlbIyNDnErhNfp

# 服務端口設置, 如果雲服務器未備案請修改 http_port 端口為其他端口
http_port=80
ssh_port=2222

# 服務安裝目錄
install_dir=/opt

Server_IP=`ip addr | grep 'state UP' -A2 | grep inet | egrep -v '(127.0.0.1|inet6|docker)' | awk '{print $2}' | tr -d "addr:" | head -n 1 | cut -d / -f1`
Docker_IP=`ip addr | grep docker.* | grep inet | awk '{print $2}' | head -n 1`

[root@cloud01 setuptools]# ./jmsctl.sh --help
JumpServer 部署安裝腳本

Usage: 
  jmsctl [COMMAND] ...
  jmsctl --help

Commands: 
  install      安裝 JumpServer
  start        啟動 JumpServer
  stop         停止 JumpServer
  restart      重啟 JumpServer
  status       檢查 JumpServer
  uninstall    卸載 JumpServer
  upgrade      升級 JumpServer
  reset        重置組件

[root@cloud01 setuptools]# docker ps -a
CONTAINER ID        IMAGE                             COMMAND             CREATED             STATUS              PORTS                                              NAMES
1dc9d1c225e9        jumpserver/jms_guacamole:v2.1.1   "./entrypoint.sh"   2 hours ago         Up 2 hours          127.0.0.1:8081->8080/tcp                           jms_guacamole
64ca610406c5        jumpserver/jms_koko:v2.1.1        "./entrypoint.sh"   2 hours ago         Up 2 hours          0.0.0.0:2222->2222/tcp, 127.0.0.1:5000->5000/tcp   jms_koko

三、jumpserver使用

3.1、郵件配置

image

3.2、用戶管理

1)創建用戶組

image

image

2)創建用戶

image

image

3.3、資產管理

1)創建管理用戶

管理用戶是資產(被控服務器)上的 root,或擁有 NOPASSWD: ALL sudo 權限的用戶, JumpServer 使用該用戶來 `推送系統用戶`、`獲取資產硬件信息` 等。

首先在被控服務器上創建管理用戶,可以使用root,我這里單獨創建一個用戶

[root@service06 ~]# useradd jump && echo "123456"|passwd --stdin jump
Changing password for user jump.
passwd: all authentication tokens updated successfully.

[root@service06 ~]# visudo
## Allow root to run any commands anywhere
root    ALL=(ALL)       ALL    
jump    ALL=(ALL)      NOPASSWD: ALL

image

image

2)創建系統用戶

系統用戶是 JumpServer 跳轉登錄資產時使用的用戶,可以理解為登錄資產用戶,如 web,sa,dba(`ssh web@some-host`),而不是使用某個用戶的用戶名跳轉登錄服務器(`ssh xiaoming@some-host`); 簡單來說是用戶使用自己的用戶名登錄 JumpServer,JumpServer 使用系統用戶登錄資產。 系統用戶創建時,如果選擇了自動推送,JumpServer 會使用 Ansible 自動推送系統用戶到資產中,如果資產(交換機)不支持 Ansible,請手動填寫賬號密碼。

image

image

image

3)創建資產

image

image

測試連接及更新硬件信息:

image

再次查看資產列表:

image

3.4、權限管理

1)資產授權

image

登錄普通用戶查看:

image

使用web終端,默認登錄之前創建的系統用戶,由jumpserver自動推送過去的

image

3.5、會話管理

1)會話管理

image

歷史回話支持回放功能:

image

image

2)命令記錄

image

3)文件管理

可以上傳下載文件,也可以對普通用戶改權限進行限制

image

3.6、作業中心

1)任務列表

image

2)批量命令

底層使用的是ansible

image

3)任務監控

image

3.7、日志審計

image


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM