1.查看當前openssl和openssh版本
openssl version -a
ssh -V
2.安裝并啟用telnet服務(wù)(防止升級過程無法連接機器)
yum -y install telnet-server xinetd
設(shè)置開機自啟
systemctl enable xinetd.service
systemctl enable telnet.socket
啟動服務(wù)
systemctl start telnet.socket
systemctl start xinetd
檢查服務(wù)是否開啟:
systemctl status telnet.socket
systemctl status xinetd
開啟root用戶在telnet登陸:
?
mv /etc/securetty /etc/securetty.bak
3.配置防火墻(關(guān)閉防火墻可不配置)
法一:直接對外開發(fā)23端口(高風險)
?#--permanent 為永久開啟,不加此參數(shù)重啟防火墻后規(guī)則不保存
firewall-cmd --add-port=23/tcp --permanent?
#重啟防火墻??
firewall-cmd --reload
法二:指定IP開放
firewall-cmd ?--permanent --add-rich-rule='rule family=ipv4 source address=10.66.9.1 port protocol=tcp port=23 accept'
firewall-cmd --reload
4.允許root遠程登錄
修改/etc/securetty文件,在末尾添加
#不一定就是這個,有可能是pts/0或者pts/1,其他可查log
pts/4
5.重啟telnet服務(wù)和守護進程
systemctl restart telnet.socket
systemctl restart xinetd.service
6.測試通過telnet登錄服務(wù)器
windows打開cmd,輸入telnet ip,進行測試
7.升級openssl(3.0.7)
#下載、解壓安裝包
wget http://www.openssl.org/source/old/3.0/openssl-3.0.7.tar.gz --no-check-certificate
tar -zxvf openssl-3.0.7.tar.gz
cd openssl-3.0.7
#安裝依賴
yum install -y gcc gcc-c++ glibc make automake autoconf pam pam-devel zlib zlib-devel
#編譯預(yù)配置
./config shared --prefix=/usr/local/openssl
#編譯安裝
make &&?make install
###老版本可備份也可不備份
#備份老版本openssl
mv /usr/bin/openssl /usr/bin/openssl.bak
mv /usr/include/openssl /usr/include/openssl.bak
#軟連接剛編譯好的新版本openssl
ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl
ln -s /usr/local/openssl/include/openssl /usr/include/openssl
#配置庫文件路徑
#注意檢查左邊的路徑下確有.so文件
echo '/usr/local/openssl/lib64' > /etc/ld.so.conf.d/openssl-x86_64.conf
#使配置生效
ldconfig -v
8.升級openssh至9.3
#下載、解壓安裝包
wget https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-9.3p1.tar.gz
tar -zxvf openssh-9.3p1.tar.gz
#更改用戶組和所有者
chown -R root.root ./openssh-9.3p1
#停止當前ssh服務(wù),停止前確保telnet可連接
systemctl stop sshd
#刪除老配置
rm -rf /etc/ssh/*
#卸載已安裝的openssh相關(guān)軟件包
rpm -e `rpm -qa | grep openssh` --nodeps
#編譯預(yù)配置
cd openssh-9.3p1
./configure --prefix=/usr/local/openssh --sysconfdir=/etc/ssh --with-zlib --with-ssl-dir=/usr/local/openssl/include/openssl --with-md5-passwords --with-pam
#編譯安裝
make && make install
#檢查并刪除老版本啟動腳本
ls /usr/lib/systemd/system/ssh*
rm -f /usr/lib/systemd/system/ssh*
#建立軟連接
ln -s /usr/local/openssh/sbin/sshd /usr/sbin/
ln -s /usr/local/openssh/bin/* /usr/bin/? ??
#重新加載系統(tǒng)管理守護進程(systemd) 的配置文件
systemctl daemon-reload
#啟動并設(shè)置開機自啟動
systemctl start sshd && systemctl enable sshd
#允許root遠程登錄
echo "PermitRootLogin yes" >> /etc/ssh/sshd_config
#重啟ssh服務(wù)
systemctl restart sshd
#查看openssh版本,驗證是否升級成功
ssh -V
#關(guān)閉telnet服務(wù),先測試ssh是否可連接
systemctl stop telnet.socket
systemctl disable telnet.socket
#刪除防火墻放行端口
firewall-cmd --remove-port=23/tcp --permanent
firewall-cmd --reload
9.編譯安裝openssh---(報錯集合)
如果報錯:
configure: error: *** zlib.h missing - please install first or check config.log ***
需要安裝zlib-devel
[root@bo-gon openssh-9.3p1]# yum install -y zlib-devel
如果報錯:
configure: error: *** OpenSSL headers missing - please install first or check config.log ***
configure: error: *** working libcrypto not found, check config.log
需要安裝openssl-devel包
[root@bo-gon openssh-9.3p1]# yum -y install openssl-devel
如果報錯:
checking whether OpenSSL's headers match the library... no
configure: error: Your OpenSSL headers do not match your
? ? ? ? library. Check config.log for details.
? ? ? ? If you are sure your installation is consistent, you can disable the check
? ? ? ? by running "./configure --without-openssl-header-check".
? ? ? ? Also see contrib/findssl.sh for help identifying header/library mismatches.
添加`--without-openssl-header-check`參數(shù)繼續(xù)編譯
?./configure --prefix=/usr --sysconfdir=/etc/ssh ?--without-openssl-header-check
?解決完報錯后重新執(zhí)行文章來源:http://www.zghlxwxcb.cn/news/detail-455306.html
./configure --prefix=/usr --sysconfdir=/etc/ssh
?完成后執(zhí)行文章來源地址http://www.zghlxwxcb.cn/news/detail-455306.html
make && makeinstall
到了這里,關(guān)于記一次修復漏洞(OpenSSH 安全漏洞(CVE-2023-28531))CentOS升級openssh的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!