升級OpenSSH版本(8.8版本)

1.前言

Hello大家好我是哈皮,最近項目中被報告低版本SSH存在漏洞,需要進行升級(升級到目前最新的8.8版本),記錄一下升級過程。

2.資源

https://github.com/openssh/openssh-portable/tags
https://github.com/openssl/openssl/tags
# 我的版本
https://github.com/happyjava007/share/raw/main/openssh-8.8p1.tar.gz
https://github.com/happyjava007/share/raw/main/openssl-3.0.1.tar.gz

3.開啟Telnet登陸

為了避免升級失敗,導(dǎo)致無法登陸服務(wù)器,所以需要開啟Telnet登陸。

systemctl start telnet.socket
telnet 127.0.0.1 # 測試是否可以正常登陸

4.升級OpenSSL

# 備份
mv /usr/bin/openssl /usr/bin/openssl_old

# 進入OpenSSL源碼目錄
./config shared && make && make install

# 檢查安裝
openssl version
# 報錯
# openssl: error while loading shared libraries: libssl.so.3: cannot open shared object file: No such file or directory
# 在OpenSSL源碼目錄
cp libssl.so.3 /usr/lib64/
cp libcrypto.so.3 /usr/lib64/

5.升級OpenSSH

# 備份
mkdir /etc/ssh_old
mv /etc/ssh/* /etc/ssh_old/

# 進入openssh目錄
./configure --prefix=/usr/ --sysconfdir=/etc/ssh --with-ssl-dir=/usr/local/lib64/ --with-zlib --with-pam --with-md5-password --with-ssl-engine --with-selinux

# 警告
PAM is enabled. You may need to install a PAM control file 
for sshd, otherwise password authentication may fail. 
Example PAM control files can be found in the contrib/ 
subdirectory

ls contrib # 里面有各種系統(tǒng)

# 備份
mv /etc/pam.d/sshd /etc/pam.d/sshd_bak
# 復(fù)制
cp contrib/redhat/sshd.pam /etc/pam.d/sshd # 根據(jù)系統(tǒng)選擇

# 安裝
make && make install

# 根據(jù)提示執(zhí)行
/usr/sbin/sshd -t -f /etc/ssh/sshd_config

vim /etc/ssh/sshd_config
PermitRootLogin yes # 開啟root登陸

# 移除舊版本的文件
mv /usr/lib/systemd/system/sshd.service /etc/ssh_old/
mv /usr/lib/systemd/system/sshd.socket /etc/ssh_old/

cp -a contrib/redhat/sshd.init /etc/init.d/sshd

systemctl daemon-reload
systemctl restart sshd

升級完后,ssh登陸可能報錯

Host key verification failed.

執(zhí)行以下命令即可

ssh-keygen -R <server_ip>
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容