本文在CentOS7.4环境下,使用源码安装方式升级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要永久关闭,否者会出现拒绝连接情况
下载源码包
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