Centos 6.5升級openssh漏洞

CentOS 6.5下openssh升級

  在有的企業中每一年都會安全掃描,由於實現遠程鏈接比較重要,若是openssh版本太低,就要對其升級,本文主要講述openssh升級的步驟。html

  openssh升級主要有三步:node

  (1) 安裝新版本的openssl

  (2) 安裝新版本的openssh

  若是是生產環境,而且存在備機,建議從備機開始升級,備機升級完了再升級主機。mysql

  詳細的過程以下:sql

  1.1  安裝zlib

  Zlib下載地址: http://www.greenxiazai.com/soft/101492.html安全

  [root@localhost ~]# tar –xf zlib-1.2.8.tar.gzssh

  [root@localhost ~]# cd zlib-1.2.8 && ./configure –shared && make  && make test && make installspa

  

   1.2  安裝新版本的openssl

  這裏給出openssl的下載地址:rest

       https://www.openssl.org/source/openssl-1.0.2i.tar.gz,htm

  若是是生產環境,請必定要先確認以前運行的服務是否支持最新的ssl連接庫。 安裝的命令以下:blog

  1)  備份以前的ssh配置及相關文件

  [root@localhost ~]# cp -raf /etc/ssh /etc/ssh.old

  [root@localhost ~]# cp -raf /etc/init.d/sshd /etc/init.d/sshd.old

  [root@localhost ~]# cp -raf /root/.ssh/ /root/.ssh.old

  2)  刪掉舊的openssl和openssh

  [root@localhost ~]# yum remove -y openssh

  [root@localhost ~]# rpm -qa | grep openssl | xargs rpm -e --nodeps

  3)  安裝openssl

  [root@localhost ~]# tar zxvf openssl-1.0.2j.tar.gz  

  [root@localhost ~]# cd openssl-1.0.2j

  [root@localhost ~]# ./config --prefix=/usr/ --shared  --openssldir=/etc/ssl  --libdir=lib zlib-dynamic

  [root@localhost ~]# make depend && make

  [root@localhost ~]# make MANDIR=/usr/share/man MANSUFFIX=ssl install && install -dv -m755 /usr/share/doc/openssl-1.0.2i  && cp -vfr doc/*    /usr/share/doc/openssl-1.0.2i

  4)  連接一些必要的庫

  [root@localhost~]#ln -s \ /usr/lib/libcrypto.so.1.0.0 /usr/lib64/libcrypto.so.1.0.0

  [root@localhost ~]# ln -s \ /usr/lib/libssl.so.1.0.0 /usr/lib64/libssl.so.1.0.0

  [root@localhost ~]# ln -s \ /usr/lib/libcrypto.so.1.0.0 /usr/lib64/libcrypto.so.10 

  [root@localhost ~]# ln -s \ /usr/lib/libssl.so.1.0.0 /usr/lib64/libssl.so.10

  若是不連接一些必要的庫,有一些程序可能會使用不了,好比yum和mysql,安裝完成以後可使用openssl version命令查看版本信息,若是顯示下面的圖片,表示安裝成功。

  1.3.  安裝並重啓openssh

  這裏給出openssh的下載地址:

       http://openbsd.hk/pub/OpenBSD/OpenSSH/portable/openssh-7.4p1.tar.g

  1)  安裝並重啓的命令以下:

  [root@localhost ~]# tar zxvf openssh-7.4p1.tar.gz

  [root@localhost ~]# cd openssh-7.4p1   

  2)  隱藏版本號配置

  [root@localhost ~]# sed -i '/SSH_VERSION/s/OpenSSH_7.4/Goodbye/g' version.h

  [root@localhost ~]# sed -i '/SSH_PORTABLE/s/p1/./g' version.h

  [root@localhost ~]# echo "/usr/include/openssl/">>/etc/ld.so.conf

  [root@localhost ~]# ldconfig

  [root@localhost~]#./configure --prefix=/usr --sysconfdir=/etc/ssh --with-md5-passwords --with-ssl-dir=/usr/local/ssl/ --with-privsep-path=/var/empty/sshd

  [root@localhost ~]# make

  [root@localhost ~]# make install &&

  [root@localhost~]# install -v -m755   contrib/ssh-copy-id /usr/bin    && install -v -m644    contrib/ssh-copy-id.1  /usr/share/man/man1 && install -v -m755 -d   /usr/share/doc/openssh-7.4p1 && install -v -m644    INSTALL LICENCE OVERVIEW README* /usr/share/doc/openssh-7.4p1

  3)  恢復備份

  [root@localhost ~]# cp -raf /etc/init.d/sshd.old /etc/init.d/sshd

  [root@localhost~]#mv /etc/ssh/sshd_config /etc/ssh/sshd_config.new

  [root@localhost~]#cp -raf/etc/ssh.old/sshd_config /etc/ssh/sshd_config

  注:一樣,若是在生產環境下,公司對出網有端口限制,那麼就要先殺死dropbear第一個監聽的端口,把sshd服務配置文件(/etc/ssh/sshd_config)中的監聽端口改掉,而後重啓sshd服務。

  [root@localhost ~]# service sshd restart

  重啓若是出現下面圖片顯示的內容:

  

  只須要在sshd配置文件中將相關項註釋掉便可,並不影響使用。
  最後將sshd服務設置爲開機自啓動。

  [root@localhost ~]# chkconfig sshd on

  4)  查看版本

  

   1.4.  注意事項

  升級完成後若是ssh拒絕root登陸,需修改配置:

  [root@localhost ~]# vi /etc/ssh/sshd_config

   

  [root@localhost ~]# service sshd restart

  [root@localhost ~]# chkconfig sshd on

  升級完成後若是使用xftp拒絕鏈接,作如下配置:

  [root@localhost ~]# vi /etc/ssh/sshd_config

  默認配置:

   

  修改後配置:

   

  重啓服務:

  [root@localhost ~]# service sshd restart 

相關文章
相關標籤/搜索