zoukankan      html  css  js  c++  java
  • 【服务器漏洞修复】openssl升级并且隐藏版本号

    1.安装所需工具

    yum install --downloadonly --downloaddir=rpm gcc gcc-c++ glibc make autoconf openssl openssl-devel pcre-devel  pam-devel krb5-devel
    yum -y install zlib zlib-devel
    yum -y install libstdc++-devel-4.8.5-44.el7.x86_64
    

    2.下载 ssh安装包以及ssl

    wget -c https://openbsd.hk/pub/OpenBSD/OpenSSH/portable/openssh-8.5p1.tar.gz
    wget -c https://ftp.openssl.org/source/openssl-1.1.1j.tar.gz
    

    3.备份ssl文件

    mv /usr/bin/openssl /usr/bin/openssl_bak 
    mv /usr/include/openssl /usr/include/openssl_bak
    

    4.解压缩ssl 压缩包、以及编译安装

    tar -zxvf openssl-1.1.1j.tar.gz
    cd openssl-1.1.1j/
    ./config --prefix=/usr/local/ssl -d shared && make -j 4 && make install
    echo $?
    

    5.创建ssl软连接

    ln -s /usr/local/ssl/bin/openssl /usr/bin/openssl
    ln -s /usr/local/ssl/include/openssl /usr/include/openssl
     ll /usr/bin/openssl
     ll /usr/include/openssl -ld
    

    6.查看ssl版本号

    echo "/usr/local/ssl/lib" >> /etc/ld.so.conf
    openssl version
    

    如果报错openssl: error while loading shared libraries: libssl.so.1.1: cannot open shared object file: No such file or directory

    查找libssl.so.1.1的目录 然后生成软链接

    find / -name "libssl.so.1.1"
    /usr/local/ssl/lib/libssl.so.1.1
    find / -name "libcrypto.so.1.1"
    /usr/local/ssl/lib/libcrypto.so.1.1
    
    ln -s /usr/local/ssl/lib/libssl.so.1.1 /usr/lib64/libssl.so.1.1 
    ln -s /usr/local/ssl/lib/libcrypto.so.1.1 /usr/lib64/libcrypto.so.1.1
    

    开始安装openssh

    1.查看ssh版本

    ssh -V 
    OpenSSH_8.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017
    

    2.备份ssh配置文件

    `mv /etc/ssh/ /opt`
    

    3.解压openssh安装包,以及编译安装,进入加压包中,找到version.h这个文件进去修改里面版本号。

    tar -zxvf openssh-8.5p1.tar.gz
    cd openssh-8.5p1
    vim version.h
    修改内容如下:
    #define SSH_VERSION     "OpenSSH"
    
    #define SSH_PORTABLE    "p1"
    #define SSH_RELEASE     SSH_VERSION SSH_PORTABLE
    退出修改
    cd ..
    cd openssh-8.5p1
    ./configure --prefix=/usr/ --sysconfdir=/etc/ssh  --with-openssl-includes=/usr/local/ssl/include --with-ssl-dir=/usr/local/ssl   --with-zlib   --with-md5-passwords   && make -j 4 && make install
    

      #如果遇到权限问题 permission 0640 for xxxx 将报权限问题的目录都设为600

    chmod -R 0600 /etc/ssh/ssh_host_ecdsa_key
    

    4.修改sshd配置

    echo "PermitRootLogin yes" >> /etc/ssh/sshd_config
    echo "UseDNS no" >> /etc/ssh/sshd_config
    

    5.从安装目录cp文件到目标位置

    cp -a contrib/redhat/sshd.init /etc/init.d/sshd
    cp -a contrib/redhat/sshd.pam /etc/pam.d/sshd.pam
    

    6.设置执行权限

    chmod +x /etc/init.d/sshd
    

    7.添加启动项

    chkconfig --add sshd
    systemctl enable sshd
    

    8.把原先的systemd管理的sshd文件删除或者移走或者删除,不移走的话影响我们重启sshd服务

    mv /usr/lib/systemd/system/sshd.service /tmp/
    

    9.设置开机启动

    chkconfig sshd on
    

    10.重启sshd、查看启动状态

    systemctl restart sshd.service
    systemctl status sshd.service
    

    11.查看ssh 22端口是否启动

    netstat -ulntp
    

    12.查看版本

    ssh -V
    OpenSSH, OpenSSL 1.1.1g  21 Apr 2020
    

    参考连接:https://www.cnblogs.com/laod/p/14283399.html

  • 相关阅读:
    取得窗口大小和窗口位置兼容所有浏览器的js代码
    一个简单易用的导出Excel类
    如何快速启动chrome插件
    网页表单设计案例
    Ubuntu下的打包解包
    The source file is different from when the module was built. Would you like the debugger to use it anyway?
    FFisher分布
    kalman filter
    Group delay Matlab simulate
    24位位图格式解析
  • 原文地址:https://www.cnblogs.com/shuideqing/p/14692018.html
Copyright © 2011-2022 走看看