标签:openssh openssl redhat7服务器打补丁 linux 博客
1.因公司服务器被绿盟扫描出openssl、openssh漏洞,所以需要升级openssl、openssh
2.操作系统:Red Hat Enterprise Linux Server release 7.2 (Maipo)
软件升级版本:openssl-1.0.2k.tar.gz、openssh-7.4p1.tar.gz
3.升级出现问题,编译安装openssh后,不会自动生成sshd.service等systemctl启动服务的文件,故提前做了备份,但觉得应该有其他的方法可以解决,希望大家提供宝贵意见
4.升级脚本根据孙磊博客脚本改编而来(http://www.cnblogs.com/elisun/p/5523696.html),安装时将脚本和两个包放在相同路径下,解决依赖请配置好YUM仓库
5.脚本updatessh.sh
#!/bin/bash #-------------------------------------| #"WARING"!!! Please use telnet-server.| #"WARING"!!! Please use telnet-server.| #"WARING"!!! Please use telnet-server.| #-------------------------------------| ssh_update() { #Backup the old files SSL_VER=openssl-1.0.2k SSH_VER=openssh-7.4p1 CUR_DIR=$(pwd) SSH_DIR=/usr/local/openssh mv /etc/ssh /etc/ssh_backup mkdir /tmp/sysdir cp /usr/lib/systemd/system/sshd* /tmp/sysdir/ cp /etc/sysconfig/sshd /tmp/sysdir/ #Update ssl yum -y install gcc gcc-c++ zlib-devel pam-devel tcp_wrappers* cd $CUR_DIR tar zxf $SSL_VER.tar.gz cd $SSL_VER ./config shared zlib make && make install mv /usr/bin/openssl /usr/bin/openssl.backup mv /usr/include/openssl /usr/include/openssl.backup ln -s /usr/local/ssl/bin/openssl /usr/bin/openssl ln -s /usr/local/ssl/include/openssl/ /usr/include/openssl echo "/usr/local/ssl/lib" >> /etc/ld.so.conf ldconfig /sbin/restorecon -v /usr/local/ssl/lib/libcrypto.so.1.0.0 cd .. #Update sshd rpm -e `rpm -qa | grep openssh` --nodeps tar zvxf $SSH_VER.tar.gz cd $SSH_VER/ ./configure --prefix=$SSH_DIR --sysconfdir=/etc/ssh --with-pam --with-tcp-wrappers --with-ssl-dir=/usr/local/ssl --with-md5-passwords --with-zlib=zlib make && make install cd $SSH_DIR mkdir /tmp/sshdir cp -rf sbin/sshd /tmp/sshdir/ mv -f /tmp/sshdir/sshd /usr/sbin/sshd cp -rf bin/ssh* /tmp/sshdir/ mv -f /tmp/sshdir/ssh* /usr/bin/ sed -i ‘s#/usr/libexec/sftp-server#/usr/local/openssh/libexec/sftp-server#‘ /etc/ssh/sshd_config sed -i ‘/#PermitRootLogin/aPermitRootLogin yes‘ /etc/ssh/sshd_config mv -f /tmp/sysdir/sshd /etc/sysconfig/sshd cp /tmp/sysdir/sshd* /usr/lib/systemd/system/ systemctl reload sshd systemctl enable sshd systemctl restart sshd.service } read -p "Are you using telnet[YES/NO]?" ANSWER case $ANSWER in YES) echo "Fine,continue!!!" ssh_update 2>&1 | tee -a /tmp/update.log ;; NO) echo "It is dangerous,bye!!!";; *) echo "Error choice";; esac
标签:openssh openssl redhat7服务器打补丁 linux 博客
原文地址:http://gongniue.blog.51cto.com/7073997/1931406