本文在CentOS7.4環(huán)境下,使用源碼安裝方式升級OpenSSL和OpenSSH
安裝后查看版本效果
# openssl version
OpenSSL 1.1.1h 22 Sep 2020
# ssh -V
OpenSSH_8.4p1, OpenSSL 1.1.1h 22 Sep 2020
安裝需要注意的事情
- 在安裝時需要卸載OpenSSH,卸載后除當前打開窗口外,不在接受新的SSH連接。
- 可以安裝Telnet,通過Telnet代替SSH連接,直到升級完畢再關閉Telnet
- 從OpenSSH6.7開始默認關閉TCPwrappers支持,也就說當升級后/etc/hosts.allow和/etc/hosts.deny配置將失效,如果有限制IP需求可以在firewalld中配置
- 升級后SELINUX要永久關閉,否者會出現(xiàn)拒絕連接情況
下載源碼包
OpenSSL下載地址:https://www.openssl.org/source/
OpenSSH下載地址:https://openbsd.hk/pub/OpenBSD/OpenSSH/portable/
下載OpenSSL和OpenSSH
# wget https://www.openssl.org/source/openssl-1.1.1h.tar.gz
# wget https://openbsd.hk/pub/OpenBSD/OpenSSH/portable/openssh-8.4p1.tar.gz
查詢當前版本
# ssh -V
OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017
卸載OpenSSL和OpenSSH
# yum remove openssl openssl-devel openssh -y
安裝OpenSSL
安裝依賴
# yum install gcc perl zlib zlib-devel -y
編譯OpenSSL
# tar -zxvf openssl-1.1.1h.tar.gz && cd openssl-1.1.1h
# ./config shared zlib --prefix=/usr/local/openssl --openssldir=/usr/local/openssl/ssl
# make && make install
配置OpenSSL
# echo "/usr/local/openssl/lib" >> /etc/ld.so.conf
# ldconfig -v
# mv /usr/bin/openssl /usr/bin/openssl.old
# ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl
查看版本
# openssl version
OpenSSL 1.1.1h 22 Sep 2020
安裝OpenSSH
安裝依賴
# yum -y install pam-devel
編譯OpenSSH
# tar -zxvf openssh-8.4p1.tar.gz && cd openssh-8.4p1
# ./configure --prefix=/usr --sysconfdir=/etc/ssh --with-openssl-includes=/usr/local/openssl/include/ --with-ssl-dir=/usr/local/openssl --with-zlib --with-md5-passwords--with-pam
# make && make install
配置OpenSSH
# echo "PermitRootLogin yes" >> /etc/ssh/sshd_config
# echo "UseDNS no" >> /etc/ssh/sshd_config
# cp -a contrib/redhat/sshd.init /etc/init.d/sshd
# chmod +x /etc/init.d/sshd
# chkconfig --add sshd
# systemctl enable sshd
# chkconfig sshd on
# chmod 600 /etc/ssh/ssh_host_rsa_key
# chmod 600 /etc/ssh/ssh_host_ecdsa_key
# /etc/init.d/sshd restart
查看版本
# ssh -V
OpenSSH_8.4p1, OpenSSL 1.1.1h 22 Sep 2020