Jumpserver官网
最新请根据官网文档步骤安装:https://jumpserver.org/
• Jumpserver 是全球首款完全开源的堡垒机, 使用 GNU GPL v2.0 开源协议, 是符合 4A 的专业运维审计系统。
• Jumpserver 使用 Python / Django 进行开发, 遵循 Web 2.0 规范, 配备了业界领先的 Web Terminal 解决方案, 交互界面美观、用户体验好。
• Jumpserver 采纳分布式架构, 支持多机房跨区域部署, 中心节点提供 API, 各机房部署登录节点, 可横向扩展、无并发访问限制。
• Jumpserver 现已支持管理 SSH、 Telnet、 RDP、 VNC 协议资产。
说明
• # 开头的行表示注释
• > 开头的行表示需要在 mysql 中执行
• $ 开头的行表示需要执行的命令
环境
• 系统: CentOS 7
• 配置:4C8G 100G
• IP: 192.168.1.189
• 目录: /opt
• 数据库: mariadb
• 代理: nginx
开始安装
$ yum update -y
$ systemctl start firewalld
$ firewall-cmd --zone=public --add-port=80/tcp --permanent # nginx 端口
$ firewall-cmd --zone=public --add-port=2222/tcp --permanent # 用户SSH登录端口 koko
–permanent 永久生效, 没有此参数重启后失效
$ firewall-cmd --reload # 重新载入规则
$ setenforce 0
$ sed -i “s/SELINUX=enforcing/SELINUX=disabled/g” /etc/selinux/config
$ yum -y install wget gcc epel-release git
$ yum -y install redis
$ systemctl enable redis
$ systemctl start redis
$ yum -y install mariadb mariadb-devel mariadb-server MariaDB-shared # centos7下叫mariadb, 用法与mysql一致
$ systemctl enable mariadb
$ systemctl start mariadb
$ DB_PASSWORD=cat /dev/urandom | tr -dc A-Za-z0-9 | head -c 24
# 生成随机数据库密码
$ echo -e “\033[31m 你的数据库密码是 $DB_PASSWORD \033[0m”
$ mysql -uroot -e “create database jumpserver default charset ‘utf8’; grant all on jumpserver.* to ‘jumpserver’@‘127.0.0.1’ identified by ‘$DB_PASSWORD’; flush privileges;”
$ vi /etc/yum.repos.d/nginx.repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=0
enabled=1
$ yum -y install nginx
$ systemctl enable nginx
$ yum -y install python36 python36-devel
$ cd /opt
$ python3.6 -m venv py3 # py3 为虚拟环境名称, 可自定义
$ source /opt/py3/bin/activate # 退出虚拟环境可以使用 deactivate 命令
(py3) [root@localhost py3]
$ cd /opt/
$ git clone --depth=1 https://github.com/jumpserver/jumpserver.git
$ yum -y install $(cat /opt/jumpserver/requirements/rpm_requirements.txt)
$ pip install wheel
$ pip install --upgrade pip setuptools
$ pip install -r /opt/jumpserver/requirements/requirements.txt -i https://mirrors.aliyun.com/pypi/simple/
$ 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”
$ vi config.yml # 确认内容有没有错误
SECRET_KEY:
BOOTSTRAP_TOKEN:
DEBUG: false
LOG_LEVEL: ERROR
SESSION_EXPIRE_AT_BROWSER_CLOSE: true
DB_ENGINE: mysql
DB_HOST: 127.0.0.1
DB_PORT: 3306
DB_USER: jumpserver
DB_PASSWORD:
DB_NAME: jumpserver
HTTP_BIND_HOST: 0.0.0.0
HTTP_LISTEN_PORT: 8080
REDIS_HOST: 127.0.0.1
REDIS_PORT: 6379
$ cd /opt/jumpserver
$ ./jms start -d # 后台运行使用 -d 参数./jms start -d
$ wget -O /usr/lib/systemd/system/jms.service https://demo.jumpserver.org/download/shell/centos/jms.service
$ chmod 755 /usr/lib/systemd/system/jms.service
$ systemctl enable jms # 配置自启
$ 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
$ mkdir /etc/docker
$ wget -O /etc/docker/daemon.json http://demo.jumpserver.org/download/docker/daemon.json
$ systemctl restart docker
$ firewall-cmd --permanent --add-rich-rule=“rule family=“ipv4” source address=“172.17.0.0/16” port protocol=“tcp” port=“8080” accept”
$ firewall-cmd --reload
$ 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
$ echo -e “\033[31m 你的服务器IP是 $Server_IP \033[0m”
$ docker run --name jms_koko -d -p 2222:2222 -p 127.0.0.1:5000:5000 -e CORE_HOST=http:// S e r v e r I P : 8080 − e B O O T S T R A P T O K E N = Server_IP:8080 -e BOOTSTRAP_TOKEN= ServerIP:8080−eBOOTSTRAPTOKEN=BOOTSTRAP_TOKEN --restart=always wojiushixiaobai/jms_koko:1.5.6
$ docker run --name jms_guacamole -d -p 127.0.0.1:8081:8080 -e JUMPSERVER_SERVER=http:// S e r v e r I P : 8080 − e B O O T S T R A P T O K E N = Server_IP:8080 -e BOOTSTRAP_TOKEN= ServerIP:8080−eBOOTSTRAPTOKEN=BOOTSTRAP_TOKEN --restart=always wojiushixiaobai/jms_guacamole:1.5.6
$ cd /opt
$ wget https://github.com/jumpserver/luna/releases/download/1.5.6/luna.tar.gz
$ wget https://demo.jumpserver.org/download/luna/1.5.6/luna.tar.gz
$ tar xf luna.tar.gz
$ chown -R root:root luna
$ rm -rf /etc/nginx/conf.d/default.conf
$ vi /etc/nginx/conf.d/jumpserver.conf
server {
listen 80;
# server_name _;
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 /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_pass http://localhost:8070;
proxy_http_version 1.1;
proxy_buffering off;
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 / {
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;
access_log off;
}
}
$ nginx -t # 确保配置没有问题, 有问题请先解决
$ systemctl start nginx
$ ssh -p2222 [email protected]
$ sftp -P2222 [email protected]
密码: admin
$ ssh [email protected] 2222
$ sftp [email protected] 2222
密码: admin
如果能登陆代表部署成功