溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

centos6.6升級openssh到最新版本7.5.p1

發(fā)布時間:2020-06-09 11:13:32 來源:網(wǎng)絡(luò) 閱讀:12237 作者:hnr1017 欄目:安全技術(shù)

本文主要簡單記錄下openssh升級步驟,及一鍵升級腳本。

安裝編譯所需工具包

yum install gcc pam-devel zlib-devel

一、升級原因

7.4以下openssh版本存在嚴重漏洞:

1.OpenSSH 遠程權(quán)限提升漏洞(CVE-2016-10010)  

2.OpenSSH J-PAKE授權(quán)問題漏洞(CVE-2010-4478)  

3.Openssh MaxAuthTries限制繞過漏洞(CVE-2015-5600)  

OpenSSL>=1.0.1可以不用升級OpenSSL

二、安裝telnet服務(wù)

1.安裝軟件

# yum -y install telnet-server* telnet

2.啟用telnet服務(wù)

# vi /etc/xinetd.d/telnet
將其中disable字段的yes改為no以啟用telnet服務(wù)
# mv /etc/securetty /etc/securetty.old    #允許root用戶通過telnet登錄
# service xinetd start                    #啟動telnet服務(wù)
# chkconfig xinetd on                     #使telnet服務(wù)開機啟動,避免升級過程中服務(wù)器意外重啟后無法遠程登錄系統(tǒng)

3.測試telnet能否正常登入系統(tǒng)

三、升級OpenSSH

1.備份當(dāng)前openssh

mv /etc/ssh /etc/ssh.old
mv /etc/init.d/sshd /etc/init.d/sshd.old

2.卸載當(dāng)前openssh

# rpm -qa | grep openssh
openssh-clients-5.3p1-104.el6.x86_64
openssh-server-5.3p1-104.el6.x86_64
openssh-5.3p1-104.el6.x86_64
openssh-askpass-5.3p1-104.el6.x86_64
# rpm -e --nodeps openssh-5.3p1-104.el6.x86_64
# rpm -e --nodeps openssh-server-5.3p1-104.el6.x86_64
# rpm -e --nodeps openssh-clients-5.3p1-104.el6.x86_64
# rpm -e --nodeps openssh-askpass-5.3p1-104.el6.x86_64
# rpm -qa | grep openssh
注意:卸載過程中如果出現(xiàn)以下錯誤
[root@node1 openssh-7.5p1]# rpm -e --nodeps openssh-server-5.3p1-104.el6.x86_64 
error reading information on service sshd: No such file or directory
error: %preun(openssh-server-5.3p1-104.el6.x86_64) scriptlet failed, exit status 1
解決方法:
# rpm -e --noscripts openssh-server-5.3p1-104.el6.x86_64

3.openssh安裝前環(huán)境配置

# install -v -m700 -d /var/lib/sshd
# chown -v root:sys /var/lib/sshd
當(dāng)前系統(tǒng)sshd用戶已經(jīng)存在的話以下不用操作
# groupadd -g 50 sshd
# useradd -c 'sshd PrivSep' -d /var/lib/sshd -g sshd -s /bin/false -u 50 sshd

4.解壓openssh_7.5p1源碼并編譯安裝

# tar -zxvf openssh-7.5p1.tar.gz
# cd openssh-7.5p1
# ./configure --prefix=/usr --sysconfdir=/etc/ssh --with-md5-passwords --with-pam --with-zlib --with-openssl-includes=/usr --with-privsep-path=/var/lib/sshd
# make
# make install

5.openssh安裝后環(huán)境配置

# 在openssh編譯目錄執(zhí)行如下命令
# 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.5p1
# install -v -m644    INSTALL LICENCE OVERVIEW README* /usr/share/doc/openssh-7.5p1
# ssh -V              #驗證是否升級成功

6.啟用OpenSSH服務(wù)

# 在openssh編譯目錄執(zhí)行如下目錄
# echo 'X11Forwarding yes' >> /etc/ssh/sshd_config
# echo "PermitRootLogin yes" >> /etc/ssh/sshd_config   #允許root用戶通過ssh登錄
# cp -p contrib/redhat/sshd.init /etc/init.d/sshd
# chmod +x /etc/init.d/sshd
# chkconfig  --add  sshd
# chkconfig  sshd  on
# chkconfig  --list  sshd
# service sshd restart

注意:如果升級操作一直是在ssh遠程會話中進行的,上述sshd服務(wù)重啟命令可能導(dǎo)致會話斷開并無法使用ssh再行登入(即ssh未能成功重啟),此時需要通過telnet登入再執(zhí)行sshd服務(wù)重啟命令。

7.重啟系統(tǒng)驗證沒問題后關(guān)閉telnet服務(wù)

# mv /etc/securetty.old /etc/securetty
# chkconfig  xinetd off
# service xinetd stop
如需還原之前的ssh配置信息,可直接刪除升級后的配置信息,恢復(fù)備份。
# rm -rf /etc/ssh
# mv /etc/ssh.old /etc/ssh

附件為一鍵升級腳本,先運行telnetserver.sh,而后在運行升級openssh腳本。

附件:http://down.51cto.com/data/2366639
向AI問一下細節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI