非常重要:若是基础环境没有正确安装,后边编译安装软件会报错~
**这是我的实验硬件配置,记得初始化好系统,永久关掉防火墙跟selinux那些,不要装docker,会冲突,然后重启一下再进行部署操作~
hostnamectl set-hostname Jumpserver #更改主机名
机器提前装好wget工具,便于进行下载
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
yum install -y bash-completion vim lrzsz wget expect nettools nc nmap tree dos2unix htop iftop iotop unzip telnet slpsmisc nethogs glances bc ntpdate openldap-devel
yum -y install git python-pip gcc automake autoconf pythondevel vim sshpass lrzsz readline-devel zlib zlib-devel openssl openssl-devel
localedef -c -f UTF-8 -i zh_CN zh_CN.UTF-8
export LC_ALL=zh_CN.UTF-8
echo 'LANG="zh_CN.UTF-8"' > /etc/locale.conf #写入配置文件,永久生效
locale
wget https://cdn.mysql.com//Downloads/MySQL-5.6/MySQL-5.6.49-1.el7.x86_64.rpm-bundle.tar
mkdir mysql_rpm
tar -xf MySQL-5.6.49-1.el7.x86_64.rpm-bundle.tar -C ./mysql_rpm/
cd mysql_rpm/
yum localinstall -y ./*
vim /etc/my.cnf #作如下修改
log-error=/var/log/mysql/mysql.log
pid-file=/var/run/mysql/mysql.pid
mysql15.6版本默认会生产随机密码,密码文件在
/root/.mysql_secret
*注意-p参数后没有空格,该方式是不安全的,密码会暴露
mysqladmin -uroot -pybZ1U3SFa7RQJCRj password xuyuhan #z注意修改成自己的密码再复制
mysql -uroot -p #回车输入密码后登陆
update mysql.user set password=password('xuyuhan') where user='root';
flush privileges; #必须刷新后,数据库密码才会改变
create database jumpserver default charset 'utf8'collate 'utf8_bin';
create user 'jumpserver'@'%' IDENTIFIED BY 'chaoge888'; #这里我的密码设置为chaoge888
grant all privileges on jumpserver.* to'jumpserver'@'%' identified by 'chaoge888';
flush privileges;
1.下载
cd /opt && wget https://www.python.org/ftp/python/3.6.10/Python-3.6.10.tgz
tar -zxf Python-3.6.10.tgz
cd Python-3.6.10/
ls
#指定位置安装,大概一分钟
./configure --prefix=/opt/python3-6-10/
ls
#编译安装,过程大概三分钟
make && make install
#配置环境变量
echo PATH="/opt/python3-6-10/bin:$PATH" >> /etc/profile
tail -1 /etc/profile
重新登录会话,可重启下主机
python #此时按tab键
python3.6 -m venv /opt/py3
#激活虚拟环境,此时PATH变量已经变化,只会影响python命令
mkdir ~/.pip
vim ~/.pip/pip.conf
#添加以下内容,把pypi默认的下载源换成国内源,一劳永逸解决pypi下载慢的问题
[global]
index-url = https://mirrors.aliyun.com/pypi/simple/
#安装
yum install redis -y
#启动
systemctl start redis
#设置开机自启
systemctl enable redis
#还是下载到/opt这里
cd /opt && wget https://github.com/jumpserver/jumpserver/releases/download/v2.1.0/jumpserver-v2.1.0.tar.gz
#解压
tar -zxvf jumpserver-v2.1.0.tar.gz
#建立软连接
ln -s /opt/jumpserver-v2.1.0//opt/jumpserver
#可能需要再次尝试这一步,我这里没报错
#先激活python3虚拟环境,然后安装
source /opt/py3/bin/activate
yum install -y bash-completion vim lrzsz wget expect net-tools nc nmap tree dos2unix htop iftop iotop unzip telnet sl psmisc nethogs glances bc ntpdate openldap-devel
cd /opt/jumpserver-v2.1.0/requirements/
pip install wheel
pip install --upgrade pip setuptools
pip install -r requirements.txt
if [ "$SECRET_KEY" = "" ]; then SECRET_KEY=`cat /dev/urandom |tr -dc A-Za-z0-9 | head -c 50`; echo "SECRET_KEY=$SECRET_KEY" >> ~/.bashrc; echo $SECRET_KEY; else echo $SECRET_KEY; fi
if [ "$BOOTSTRAP_TOKEN" = "" ]; then BOOTSTRAP_TOKEN=`cat /dev/urandom | tr -dc A-Za-z0-9 | head -c 16`; echo
"BOOTSTRAP_TOKEN=$BOOTSTRAP_TOKEN" >> ~/.bashrc; echo $BOOTSTRAP_TOKEN; else echo $BOOTSTRAP_TOKEN; fi
备份配置文件
cd /opt/jumpserver-v2.1.0 && cp config_example.yml config.yml #切记要备份成config.yml 这名称,不然迁移数据库会报错,检查了好久
#修改配置文件,有如下修改
grep -Ev '^#|^$'config.yml
SECRET_KEY: "$SECRET_KEY"
BOOTSTRAP_TOKEN: "$BOOTSTRAP_TOKEN"
DEBUG: true
LOG_LEVEL: DEBUG
SESSION_EXPIRE_AT_BROWSER_CLOSE: false
DB_ENGINE: mysql
DB_HOST: 127.0.0.1
DB_PORT: 3306
DB_USER: jumpserver
DB_PASSWORD: chaoge888
DB_NAME: jumpserver
HTTP_BIND_HOST: 0.0.0.0
HTTP_LISTEN_PORT: 8080
WS_LISTEN_PORT: 8070
REDIS_HOST: 127.0.0.1
REDIS_PORT: 6379
python3 /opt/jumpserver-v2.1.0/apps/manage.py makemigrations
python3 /opt/jumpserver-v2.1.0/apps/manage.py migrate
#确保都是在python虚拟环境下进行
(py3) [root@jumpserver jumpserver-v2.1.0]# cd /opt/jumpserver-v2.1.0
(py3) [root@jumpserver jumpserver-v2.1.0]# ./jms start -d
#j记得koko版本要跟jumpserver一致,否则无法进行web端远程连接
cd /opt && wget https://github.com/jumpserver/koko/releases/download/v2.21.0/koko-v2.21.0-linux-amd64.tar.gz
[root@jumpserver opt]# tar -xf koko-v2.21.0-linux-amd64.tar.gz
[root@jumpserver opt]# mv koo koko
[root@jumpserver opt]# cd koko
[root@jumpserver koko]# ls
[root@jumpserver koko]# cp config_example.yml config.yml
[root@jumpserver koko]# vim config.yml
#修改后如下
(py3) [root@jumpserver koko 09:45:20]$grep -Ev '^#|^$'/opt/koko/config.yml
CORE_HOST: http://127.0.0.1:8080
BOOTSTRAP_TOKEN: "$BOOTSTRAP_TOKEN"
LOG_LEVEL: INFO
REDIS_HOST: 127.0.0.1
REDIS_PORT: 6379
REDIS_PASSWORD:
REDIS_CLUSTERS:
REDIS_DB_ROOM:
(py3) [root@jumpserver koko]# /opt/koko/koko -d #让koko后台运行
(py3) [root@jumpserver koko]#
后边要能在web端打开这个文件管理才可以,非正常安装会出现502报错
该软件包github已经找不到了,可以通过docker下载,这里直接提供网盘链接
链接: https://pan.baidu.com/s/1nVuD2NEYfEXkb80DPA0rtQ?pwd=2hwd 提取码: 2hwd 复制这段内容后打开百度网盘手机App,操作更方便哦
(py3) [root@jumpserver opt]# tar -xf guacamole-v2.1.0.tar.gz
(py3) [root@jumpserver opt]# mv docker-guacamole-2.1.0 guacamole
(py3) [root@jumpserver opt]# cd /opt/guacamole && tar -xf guacamole-server-1.2.0.tar.gz && tar -xf ssh-forward.tar.gz -C /bin/
(py3) [root@jumpserver guacamole]# chmod +x /bin/ssh-forward
(py3) [root@jumpserver guacamole]# cd /opt/guacamole/guacamole-server-1.2.0/
根据官方文档的要求来
http://guacamole.apache.org/doc/gug/installing-guacamole.html
#非常重要,必须安装
yum install cairo-devel libjpeg-turbo-devel libpng-devel libtool uuid-devel -y
yum install freerdp-devel pango-devel libssh2-devel libtelnet-devel libvncserver-devel libwebsockets-devel pulseaudio-libs-devel openssl-devel libvorbis-devel libwebp-devel -y
sudo yum install epel-release -y
sudo rpm -v --import http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro
sudo rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm
yum install ffmpeg ffmpeg-devell -y
ffmpeg -version
cd /opt/guacamole/guacamole-server-1.2.0
./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
(py3) [root@jumpserver opt]# cd /opt/ && wget https://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-9/v9.0.62/bin/apache-tomcat-9.0.62.tar.gz
cd /opt
tar -xf apache-tomcat-9.0.62.tar.gz
mv apache-tomcat-9.0.62 tomcat9
rm -rf /opt/tomcat9/webapps/*
sed -i 's/Connector port="8080"/Connector port="8081"/g' /opt/tomcat9/conf/server.xml
echo "java.util.logging.ConsoleHandler.encoding = UTF-8" >> /opt/tomcat9/conf/logging.properties
ln -sf /opt/guacamole/guacamole-1.0.0.war /opt/tomcat9/webapps/ROOT.war
ln -sf /opt/guacamole/guacamole-auth-jumpserver-1.0.0.jar /config/guacamole/extensions/guacamole-auth-jumpserver-1.0.0.jar
ln -sf /opt/guacamole/root/app/guacamole/guacamole.properties /config/guacamole/guacamole.properties
export JUMPSERVER_SERVER=http://127.0.0.1:8080
echo "export JUMPSERVER_SERVER=http://127.0.0.1:8080" >> ~/.bashrc
export BOOTSTRAP_TOKEN=FBEVLP0OKHmNqRMl
export BOOTSTRAP_TOKEN=FBEVLP0OKHmNqRMl >> ~/.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
export GUACAMOLE_LOG_LEVEL=ERROR
echo "export GUACAMOLE_LOG_LEVEL=ERROR" >> ~/.bashrc
export JUMPSERVER_ENABLE_DRIVE=true
echo "export JUMPSERVER_ENABLE_DRIVE=true" >> ~/.bashrc
(py3) [root@jumpserver opt]# tail -8 ~/.bashrc
/etc/init.d/guacd start
sh /opt/tomcat9/bin/startup.sh
cd /opt &&wget https://github.com/jumpserver/lina/releases/download/v2.21.0/lina-v2.21.0.tar.gz
tar -xf lina-v2.21.0.tar.gz
mv lina-v2.21.0.tar.gz lina
#安装nginx
yum install nginx -y
systemctl start nginx
systemctl enable nginx
chown -R nginx:nginx lina # 需要提前装好nginx
下载地址:https://github.com/jumpserver/luna/releases
cd /opt && wget https://github.com/jumpserver/luna/releases/download/v2.21.0/luna-v2.21.0.tar.gz
tar -zxf luna-v2.21.0.tar.gz
mv /opt/luna-v2.21.0 /opt/luna
chown -R root.root /opt/luna/
#修改nginx.conf,去掉原有的虚拟主机地址
cd /etc/nginx/nginx.conf
sed -i '38,58d' /etc/nginx/nginx.conf
vim /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-v2.1.0/data/; #录像位置,如果修改安装目录,此处需要修改
}
location /static/ {
root /opt/jumpserver-v2.1.0/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
nginx -s reload
##执行nginx -t 测试时如果出现错误,记得检查好jumpserver.conf配置文件内容格式,不要少了括号啥的~
192.168.230.206:80 #我的主机地址
***记录下这个错误解决方法,部署过程有重启过主机或者nginx服务的,记得要重新进入python3虚拟环境环境重新启动下jms
[root@jumpserver jumpserver-v2.1.0]# source /opt/py3/bin/activate
(py3) [root@jumpserver jumpserver-v2.1.0]# ./jms start -d
至此koko组件其实没法正常运行,导致无法使用权限管理的文件管理以及web端远程连接功能,需要做以下操作解决~ 懒得写了,截图哈哈哈
#执行命令重新生成前请先删掉原本的密钥
if [ "$SECRET_KEY" = "" ]; then SECRET_KEY=`cat /dev/urandom |tr -dc A-Za-z0-9 | head -c 50`; echo "SECRET_KEY=$SECRET_KEY" >> ~/.bashrc; echo $SECRET_KEY; else echo $SECRET_KEY; fi
if [ "$BOOTSTRAP_TOKEN" = "" ]; then BOOTSTRAP_TOKEN=`cat /dev/urandom | tr -dc A-Za-z0-9 | head -c 16`; echo "BOOTSTRAP_TOKEN=$BOOTSTRAP_TOKEN" >> ~/.bashrc; echo $BOOTSTRAP_TOKEN; else echo $BOOTSTRAP_TOKEN; fi
systemctl start mysql #启动
systemctl enable mysql #设置开机自启
#确保都是在python虚拟环境下进行
[root@jumpserver jumpserver-v2.1.0]# source /opt/py3/bin/activate
(py3) [root@jumpserver jumpserver-v2.1.0]# /opt/jumpserver-v2.1.0/jms start -d
#启动
systemctl start redis
#设置开机自启
systemctl enable redis
source /opt/py3/bin/activate #先进入python3虚拟环境
(py3) [root@jumpserver jumpserver-v2.1.0]# /opt/koko/koko -d #没报错
/etc/init.d/guacd start
sh /opt/tomcat9/bin/startup.sh
systemctl start nginx #启动
systemctl status nginx #查看状态
systemctl restart nginx #重启
nginx -t #测试config文件是否正常
nginx -s reload #重新加载