美文网首页
Ubuntu一键升级OpenSSH脚本

Ubuntu一键升级OpenSSH脚本

作者: qboy0000 | 来源:发表于2020-04-23 16:08 被阅读0次

    申明:以下脚本为本人在实践过程中所编写

    #!/bin/bash
    
    if [ "$(whoami)" != "root" ]
    then
        echo -e "You must be root to run this script"
        exit 1
    fi
    
    set -x
    set -e
    
    ZLIB=1.2.11
    #download_url=http://www.zlib.net/zlib-1.2.11.tar.gz
    OPENSSL=1.1.1g
    #download_url=https://www.openssl.org/source/openssl-1.1.1g.tar.gz
    OPENSSH=8.2p1
    #download_url=https://fastly.cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-8.2p1.tar.gz
    
    function update_sources(){
        sed -i 's/cn.archive.ubuntu.com/mirrors.huaweicloud.com/g' /etc/apt/sources.list
        sed -i 's/security.ubuntu.com/mirrors.huaweicloud.com/g' /etc/apt/sources.list
    
        apt update 
        apt install -y gcc make
    }
    update_sources
    
    function INSTALL_ZLIB(){
        wget http://www.zlib.net/zlib-${ZLIB}.tar.gz -O /tmp/zlib-${ZLIB}.tar.gz
        cd /tmp/
        tar -xvf zlib-${ZLIB}.tar.gz
        cd /tmp/zlib-${ZLIB}
        ./configure
        make -j4
        make install
        cd ..
    }
    
    function INSTALL_OPENSSL(){
        wget https://www.openssl.org/source/openssl-${OPENSSL}.tar.gz -O /tmp/openssl-${OPENSSL}.tar.gz
        if [ -f /usr/bin/openssl ]; then
            mv /usr/bin/openssl /usr/bin/openssl.old
        fi
        cd /tmp
        tar -xvf openssl-${OPENSSL}.tar.gz
        cd openssl-${OPENSSL}
        ./config
        make -j4 
        make install 
    
        ldconfig 
    
        openssl version
        cd ..
    }
    
    function INSTALL_OPENSSH(){
        apt install -y libpam0g-dev 
        wget https://fastly.cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-${OPENSSH}.tar.gz -O /tmp/openssh-${OPENSSH}.tar.gz
        cd /tmp
        tar -xvf openssh-${OPENSSH}.tar.gz
        cd openssh-${OPENSSH}
        ./configure  --sysconfdir=/etc/ssh --with-md5-passwords --with-pam --with-zlib --with-ssl-dir=/usr/local/ssl --with-privsep-path=/var/lib/sshd
        make -j4
        make install
    
        ssh -V
        cd ..
    }
    
    INSTALL_ZLIB
    INSTALL_OPENSSL
    INSTALL_OPENSSH
    

    相关文章

      网友评论

          本文标题:Ubuntu一键升级OpenSSH脚本

          本文链接:https://www.haomeiwen.com/subject/kzyaihtx.html