SUSE11升級ssh版本修復ssh漏洞

       最近一個客戶方給了一個系統漏洞掃描報告,報告中涉及很多ssh漏洞,遂,上機檢查openssh的版本,並計劃升級ssh版本,來修復這些漏洞,因爲客戶這邊的服務器是suse,平常使用的也不多,這裏在事後留個記錄。

       現場環境:SUSE11-sp3   SSH版本:OpenSSH6.2p2   SSL版本:OpenSSL 0.98j-fips

       升級準備:

下載以下對應的更新包:
#http://www.rpmfind.net/linux/rpm2html/search.php?query=&submit=Search+...&system=&arch=
libopenssl-devel-1.0.2j-38.1.x86_64.rpm
telnet-server-1.2-147.5.1.x86_64.rpm
zlib-devel-1.2.11-10.1.x86_64.rpm

#http://www.zlib.net/
zlib-1.2.11.tar.gz

#https://www.openssl.org/source/
openssl-1.0.2s.tar.gz

#https://openbsd.hk/pub/OpenBSD/OpenSSH/portable/
 openssh-8.0p1.tar.gz

         升級準備步驟:

  rpm -ivh telnet-server-1.2-147.5.1.x86_64.rpm --nodeps
  rpm -ivh libopenssl-devel-1.0.2j-38.1.x86_64.rpm --nodeps
  rpm -ivh zlib-devel-1.2.11-10.1.x86_64.rpm 

編輯/etc/xinetd.d/telnet將disable 改爲yes,
重啓/etc/init.d/xinetd restart 然後telnet鏈接是否能登陸到此服務器
若不能使用telnet登陸則註釋掉/etc/pam.d/login 下的包含pam_securetty.so的行,重啓xinetd服務即可。

需要注意的是:這裏安裝telnet是選擇性的安裝,避免因爲升級失敗,ssh斷開無法進入造成不必要的麻煩,如果是虛機,或者能方便進入服務器則不需要這裏的telnet安裝,zlib及openssl-devel是後面需要編譯的時候依賴的,故提前安裝。

         升級前備份:

openssl version
whereis openssl 將查找出來的openssl路徑的內容做備份

cp /etc/ssl /etc/ssl-bak
cp /usr/bin/openssl /usr/bin/openssl-bak
cp -r /usr/include/openssl /usr/include/openssl-bak
cp -r ./etc/ssh  /etc/ssh-bak
cp -r /etc/init.d/sshd  /etc/init.d/sshd-bak

        編譯zlib:

cd zlib-1.2.11   
./configure --shared    
make&& make install

安裝zlib是爲了防止後面編譯(make) openssl 的時候報錯***ld:cannot find -lz collect2:ld returnet 1 exit status

        升級openssl:

#編譯安裝openssl
cd  ../openssl-1.0.2s  
 ./config --prefix=/usr/local/openssl --openssldir=/etc/ssl shared zlib
 make && make install


#創建openssl的鏈接目錄
ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl 
(我這裏報錯說文件存在,因爲之前備份的時候是cp的,所以這裏直接把這個/usr/bin/openssl 刪掉,然後重新鏈接)
ln -s /usr/local/openssl/include/openssl /usr/include/openssl

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

#刷新鏈接庫
ldconfig

#查看版本信息是否變爲1.0.2s
openssl version  

        升級openssh

#停止sshd服務並卸載舊版本
service sshd stop
zypper rm openssh


#編譯新版本
cd ../openssh-8.0p1
./configure --prefix=/usr --sysconfdir=/etc/ssh --with-pam --with-openssl --with-md5-passwords --mandir=/usr/share/man --with-zlib --with-ssl-engine --with-ssl-dir=/usr/local/openssl

make 
make install

#查看新安裝的版本
ssh -V 
#複製啓動腳本
cd contrib/suse
cp rc.sshd /etc/init.d/sshd 
chmod 755 /etc/init.d/sshd
#修改ssh配置文件,允許root登陸和密碼驗證
vim /etc/ssh/sshd_config
修改PermitRootLogin yes
去掉註釋 PasswordAuthentication

/etc/init.d/sshd start 
#嘗試登陸是否正常

#增加開機啓動
chkconfig --add sshd
chkconfig sshd on

#關閉telnet服務,避免開放多餘端口,也避免後期被掃出來telnet上面的漏洞
/etc/init.d/xinetd stop
編輯/etc/xinetd.d/telnet將disable 改爲no

      至此,升級完成。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章