Upgrade OpenSSL and OpenSSH under CentOS7

CentOS 7.7.1908 version upgrade openssl and openssh

The environment is as follows

1、 First check the current openssl and openssh versions

[ root@VMServer ~]# cat /etc/redhat-release
CentOS Linux release 7.7.1908(Core)[root@VMServer ~]# openssl version
OpenSSL 1.0.2k-fips  26 Jan 2017[root@VMServer ~]# ssh -V
OpenSSH_7.4p1, OpenSSL 1.0.2k-fips  26 Jan 2017[root@VMServer ~]# rpm -qa | grep openss
openssl098e-0.9.8e-29.el7.centos.3.x86_64
openssh-7.4p1-21.el7.x86_64
openssl-1.0.2k-19.el7.x86_64
openssh-server-7.4p1-21.el7.x86_64
openssh-clients-7.4p1-21.el7.x86_64
openssl-libs-1.0.2k-19.el7.x86_64
xmlsec1-openssl-1.2.20-7.el7_4.x86_64
[ root@VMServer ~]#

2、 Upgrade openssl first

mv openssl-1.1.1g.tar.gz /opt
cd /opt
# Unzip openssl-1.1.1g source package
tar -zxvf openssl-1.1.1g.tar.gz
cd openssl-1.1.1g/
# Environment configuration before compilation
. /config --prefix=/usr/local/openssl
. /config -t
# make compile
make
# make install compile and install
make install
# Check function library
ldd /usr/local/openssl/bin/openssl
# Add missing library
echo "/usr/local/openssl/lib">>/etc/ld.so.conf
# Update function library
ldconfig -v
# Remove the old version of openssl
mv /usr/bin/openssl /usr/bin/openssl_old_bak
# Soft link the new version of openssl to/usr/bin/Under contents
ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl
# Check version
which openssl
openssl version -a

Check the version information after upgrading openssl

3、 Upgrade openssh again

# Copy openssh-8.2p1.tar.gz source package to/opt directory
cp /root/openssh-8.2p1.tar.gz /opt
cd /opt
# If you can access the Internet, you can directly yum install zlib-devel pam-devel
# yum -y install zlib-devel
# yum -y install pam-devel
# If you cannot access the Internet, download zlib in advance-devel and pam-rpm package required by devel, local rpm-ivh --Install by force
rpm -ivh --force zlib*.rpm
rpm -ivh --force pam*.rpm

# Unzip openssh-8.2p1.tar.gz source package
tar -zxvf openssh-8.2p1.tar.gz
cd openssh-8.2p1/
# Backup old version
mv /etc/ssh /etc/ssh_bak
sleep 1
# Environment configuration before compilation
. /configure --prefix=/usr/local/openssh --sysconfdir=/etc/ssh --with-pam --with-ssl-dir=/usr/local/openssl --with-md5-passwords --mandir=/usr/share/man --with-zlib=/usr/local/zlib --without-hardening
# make compile
make
# make install compile and install
make install

# modify/etc/ssh/sshd_config configuration, allowing root user SSH login, because openssh-8.This option is not available in 2p1 configuration
echo "PermitRootLogin yes">>/etc/ssh/sshd_config
# Backup old version of sshd
mv /usr/sbin/sshd /usr/sbin/sshd_bak
mv /etc/sysconfig/sshd /opt
mv  /usr/lib/systemd/system/sshd.service  /opt

# Copy the new version of sshd to/usr/sbin/
\ cp -arf /usr/local/openssh/sbin/sshd /usr/sbin/sshd
# Uninstall the original openssh
for i in$(rpm -qa |grep openssh);do rpm -e $i --nodeps ;done

# After uninstalling, the openssh configuration file will become the rpmsave suffix and restore it to the original directory
mv /etc/ssh/sshd_config.rpmsave /etc/ssh/sshd_config
mv /etc/ssh/ssh_config.rpmsave /etc/ssh/ssh_config
mv /etc/ssh/moduli.rpmsave /etc/ssh/moduli
# Replace the new version of openssh related commands
\ cp -arf /usr/local/openssh/bin/* /usr/bin/
\ cp -arf /usr/local/openssh/sbin/sshd /usr/sbin/sshd

# Copy startup script
cp /opt/openssh-8.2p1/contrib/redhat/sshd.init /etc/init.d/sshd
# Add execution permissions to the startup script
chmod +x /etc/init.d/sshd
# Copy sshd.pam
cp -a contrib/redhat/sshd.pam /etc/pam.d/sshd.pam

# Restart the sshd service and set it to start at boot
systemctl daemon-reload
service sshd restart
chkconfig --add sshd
chkconfig --level 2345 sshd on
chkconfig --list

The above operations can all be written into the script

4、 Finally verify the version information of openssh

Several methods can be verified

ssh -V
nc -v 127.0.0.122
telnet 127.0.0.122
ssh -v localhost

You can see that it has been upgraded to openssh 8.2p1

This article refers to http://www.dengb.com/Linuxjc/1355285.html

Recommended Posts

Upgrade OpenSSL and OpenSSH under CentOS7
Centos6.5 openssh upgrade
Install and configure keepalived under CentOS 5.9
Compile and install LAMP under Centos 5.2
Deploy and optimize Tomcat under Centos
Java-JDK installation and configuration under CentOS
Install Python3 and ansible under CentOS8
Install and use docker under CentOS 6.8
Install Python3 and Py under CentOS7
Manually upgrade node version under CentOs
Manually upgrade node version under CentOs
Erlang 20.2 installation and deployment under CentOS 7
Install Mono 3.2 and Jexus 5.4 under CentOS 6.3
Compile and install libmodbus library under CentOS7
Installation and use of Mysql under CentOS
Tomcat installation and configuration under CentOS 7 (Tomcat startup)
Installation and configuration of redis under centos7
Centos python3 compile installation and compile gcc upgrade
Zabbix installation and deployment and localization under CentOS
Jenkins installation and deployment tutorial under CentOS 7
Install Mono 2.10.8 and Jexus 5.0 under 32- and 64-bit CentOS 6.0
KVM installation and preliminary use under CentOS 7.2
CentOS7 upgrade python3
Centos7 upgrade kernel
ubuntu14.04.1 upgrade openssh
centos6.9 rabbitmq 3.6.8 upgrade 3.8.2
CentOS 7 installation and configuration graphic tutorials under VMware10
Install svn and configuration through yum under CentOS
Installation and configuration of rsync server under CentOS 6.5
MySQL 8.0 installation and deployment under CentOS, super detailed!
Installing CentOS 6 and SSH configuration under Windows 8 Hyper-V
Install centos7 and connect
Installation and cracking of confluence6.3 operation records under Centos
Deploy GitBook under CentOS7
CentOS7.5-1804 system kernel upgrade
Centos 6.4 python 2.6 upgrade to 2.7
Vmware-install and start Centos 8
Compile Hadoop-2.7.6 under CentOS7.4
Centos 6.4 python 2.6 upgrade to 2.7
Vmware-install and start Centos 7
Install ActiveMQ under Centos7
Installation and cracking of Jira7 operation records under Centos
Install PostgreSQL12 under CentOS7
Install CentOS under VMware
[python] python2 and python3 under ubuntu
CentOS6.5 upgrade kernel to 3.10.28
Deploy JDK+Tomcat8 under CentOS
Centos kernel version upgrade
Install mysql under Centos 7
Configure lamp under centos6.8
Install Jenkins under Centos 7
Redis3 installation under Centos7
Install MariaDB under MariaDB Centos7
Install mysql5.1 under CentOS6.5
Environment configuration of JDK, mysql and tomcat under Centos7
Compile and install Lnmp shell script under Linux centos
Detailed explanation of Spark installation and configuration tutorial under centOS7
Deployment of vulnerability scanning and analysis software Nessus under CentOS
Basic usage and examples of yum under Liunx (centos8) (recommended)
Use Jexus 5.8.2 to deploy and run Asp.net core under Centos
Xen virtualization combat under CentOS 6.6