0x00
? 由于openssh版本過低贮配,漏洞掃描給出安全漏洞CVE-2020-15778禾唁,基于安全的考慮,需要將centos7.6.10系統(tǒng)的openssh_7.4p1升級到最新版本openssh_8.4p1【于2021年3月3日更新】尝苇。
? 為了避免升級失敗,先安裝Telnet服務(wù)后再進(jìn)行升級恨统,升級完成后卸載Telnet服務(wù)疯淫。
0x01
一歉糜、安裝Telnet服務(wù)并配置
yum -y install telnet telnet-server xinetd
service iptable save? ? ? ? ? ? ? ? ? ? //保存防火墻配置
service iptables stop? ? ? ? ? ? ? ? ? ? //關(guān)閉防火墻
sed -i 's/\(.*\)disable\(.*\)/\ \ \ \ \ \ \ \ disable\ \ \ \ \ \ =\ no/g' /etc/xinetd.d/telnet? ? ? ? ? ? ?//修改Telnet配置文件 ????disable=no
cp /etc/securtty /etc/securetty.bak? ? ? ? ? ? //備份securetty
echo "pts/0" >>/etc/securetty
echo "pts/1" >>/etc/securetty? ? ? ? ? ? ????//可v以多添加幾個窗口宪卿,到pts/5
service xinetd start? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? //啟動服務(wù)
chkconfig xinetd on????????????????????????
netstat -ntp|grep 23? ? ? ? ? ? ? ? ? ? ? ? ? ? //查看23端口是否處于監(jiān)聽狀態(tài)
安裝完成后進(jìn)行測試telnet服務(wù)器是否能正常登陸后再進(jìn)行升級的诵。
二、檢查系統(tǒng)環(huán)境
[root@localhost ~]# openssl version
OpenSSL 1.0.1e-fips 11 Feb 2013
[root@localhost ~]# rpm -q zlib
zlib-1.2.3-29.el6.x86_64
[root@localhost ~]# rpm -q zlib-devel
zlib-devel-1.2.3-29.el6.x86_64
目前自帶的openssl版本符合安裝條件佑钾,自帶的zlib也符合依賴西疤。如果達(dá)不到版本可以進(jìn)行升級后進(jìn)行openssh升級
三、安裝相關(guān)組件后升級openssh版本
yum install -y gcc gcc-c++ glibc make autoconf? openssl-devel pcre-devel pam-devel rpm-build? ? //安裝依賴
wget -P /usr/local/src?https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-8.4p1.tar.gz?? ? ? ?//下載安裝包
官網(wǎng)更新的下載地址:https://www.openssh.com/portable.html#http
rpm -e? `rpm -qa|grep openssh`? ?--nodeps? ? ?//卸載系統(tǒng)自帶的openssh? ? ?
cd /usr/local/src && tar -zxf openssh-8.4p1.tar.gz && cd openssh-8.4p1? ? ? ? //解壓openssh安裝包
./configure --prefix=/usr/ --sysconfdir=/etc/ssh --with-zlib --with-md5-passwords --with-pam --with-tcp-wrappers && make && make install? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?//編譯安裝
sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin\ yes/g' /etc/ssh/sshd_config
sed -i 's/#PermitEmptyPasswords\(.*\)/PermitEmptyPasswords\ no/g' /etc/ssh/sshd_config? ?//修改配置文件
cp /usr/local/src/openssh-8.4p1/contrib/redhat/sshd.init? ?/etc/init.d/sshd? ??
?chmod 600 /etc/ssh/ssh_host_rsa_key /etc/ssh/ssh_host_ecdsa_key /etc/ssh/ssh_host_ed25519_key? ?//更改權(quán)限次绘,否則會報權(quán)限過大錯誤
chkconfig --add sshd
chkconfig sshd on
systemctl? start sshd
systemctl? restart? ?sshd?
ssh -V? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? //此時顯示openssh8.4p1
exit
升級完成后瘪阁,退出服務(wù)器后重新登錄。確認(rèn)ssh可以登錄服務(wù)器
四邮偎、卸載Telnet服務(wù)
mv /etc/securetty.bak /etc/securetty
service xinetd stop
chkconfig xinetd off
service iptables start
chkconfig iptables on
yum remove telnet-server xinetd? ? ? ? ? ? ? ? //卸載Telnet