在升級Openssh之后,確保還可以通過其它方式遠程登錄到服務器上,比如Telnet或阿里雲控制台。
1. 當前系統版本信息
# /usr/bin/ssh -V
OpenSSH_8.0p1, OpenSSL 1.1.1g FIPS 21 Apr 2020
# openssl version
OpenSSL 1.1.1g FIPS 21 Apr 2020
# lsb_release -a
LSB Version: :core-4.1-amd64:core-4.1-noarch
Distributor ID: AlibabaCloud
Description: Alibaba Cloud Linux release 3 (Soaring Falcon)
Release: 3
Codename: SoaringFalcon
2. Update system(生產環境慎重執行該命令,否則升級后有可能導致應用系統出現兼容性問題)
# yum update
3. 安裝開發環境及依賴包
# yum groupinstall "Development Tools"
# yum install pam-devel libselinux-devel zlib-devel openssl-devel
4. 備份原ssh配置文件(直接重命名/etc/ssh目錄,否則在安裝新版本Openssh時,無法替換配置文件)
mv /etc/ssh /opt/ssh_bak
5. 下載並安裝最新版本的Openssh
# wget https://mirrors.aliyun.com/pub/OpenBSD/OpenSSH/portable/openssh-8.8p1.tar.gz
# tar -zxvf openssh-8.8p1.tar.gz
6. 編譯並安裝openssh-8.8p1
# ./configure --with-md5-passwords --with-pam --with-selinux --with-privsep-path=/var/lib/sshd/ --sysconfdir=/etc/ssh
# make
# make install
7. PermitRootLogin 修改配置文件的下列參數,允許root帳號遠程登錄到服務器上。
# vi /etc/ssh/sshd_config
PermitRootLogin Yes
8. restart SSH and check the version of OpenSSH
# systemctl restart sshd
# ssh -V
OpenSSH_8.8p1, OpenSSL 1.1.1g FIPS 21 Apr 2020
