概述

最近在开发一个运维系统,其中有个需求【在页面上连接到服务器终端】,找到一个找到了一个使用python和js做的基于Web的SSH工具 webssh。执行下面脚本安装完成。

安装脚本

#!/bin/bash
#  -------------+-----------------------
# * Filename    :     install_wssh.sh
# * Date        :       2020-08-24 
# * Author      :      wangjianxiong           
# * Description :                       
#  -------------+-----------------------

yum -y install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel wget gcc
if [ $? -eq 0 ];then
    [ ! -f Python-3.6.5.tgz ] && wget https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tgz
    if [ $? -eq 0 ];then
        tar zxvf Python-3.6.5.tgz
    else
        echo "Python-3.6.5.tgz下载失败,请重新执行: \n wget https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tgz"
    fi
else
    echo "python 依赖包安装失败,请重新执行: \n yum -y install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel wget gcc"
fi

cd Python-3.6.5
mkdir -p /usr/local/python3/
./configure --prefix=/usr/local/python3/
if [ $? -eq 0 ];then
    make && make install
    if [ $? -eq 0 ];then
        cd /usr/local/python3/bin
        ./pip3 install --upgrade pip
        if [ $? -eq 0 ];then
            ./pip3 install webssh
             if [ $? -eq 0 ];then
                 sedsit ./wssh &
                 if [ $? -eq 0 ];then
                     echo "访问地址:http://localhost:8888"
                 else
                     echo "wssh 启动失败,请重新执行: \n ./wssh"
                 fi
             else
                 echo "webssh 安装失败,请重新执行: \n ./pip3 install webssh"
             fi
        else
            echo "升级pip失败,请重新执行: \n ./pip3 install --upgrade pip"
            exit 1
        fi
    else
        ecoh "编译失败,请重新执行: \n make && make install"
        exit 1
    fi
else
    echo "编译失败,请重新执行: \n ./configure --prefix=/usr/local/python3/"
    exit 1
fi
View Code

测试

如果你的网络不好,需要离线安装的请联系我VX:wangjianxiong000834(一元红包,非诚勿扰)