CentOS6.5版本升级openssl-1.1.1g与openssh-8.3p1

准备条件 openssl与openssh的源码包

​​

​​

​​

openssl升级

1、上传openssl与openssh的源码包,并解压

cd /usr/local/src/
cp /root/openssl-1.1.1g.tar.gz ./
tar -zxf openssl-1.1.1g.tar.gz

CentOS6.5下升级openssl-1.1.1g与openssh-8.3p1_文件拷贝

CentOS6.5下升级openssl-1.1.1g与openssh-8.3p1_文件拷贝_02

2、编译安装openssl

cd /usr/local/src/openssl-1.1.1g
./config --prefix=/usr/local/openssl --openssldir=/usr/local/openssl --shared zlib
然后执行make
如果出现如下报错
make[1]: *** [crypto/comp/c_zlib.o] Error 1
yum install zlib-devel -y
然后重新make
make install

CentOS6.5下升级openssl-1.1.1g与openssh-8.3p1_源码包_03

CentOS6.5下升级openssl-1.1.1g与openssh-8.3p1_编译安装_04

CentOS6.5下升级openssl-1.1.1g与openssh-8.3p1_文件拷贝_05

出现该报错时yum install zlib-devel后再次make编译

make无报错后make install

CentOS6.5下升级openssl-1.1.1g与openssh-8.3p1_编译安装_06

CentOS6.5下升级openssl-1.1.1g与openssh-8.3p1_文件拷贝_07


3、lib库文件拷贝

mv /usr/bin/openssl /usr/bin/openssl_1.0.1e_bak
cp /usr/local/openssl/bin/openssl /usr/bin/openssl
openssl
ldd `which openssl`
cp /usr/local/openssl/lib/libssl.so.1.1 /usr/lib64/
cp /usr/local/openssl/lib/libcrypto.so.1.1 /usr/lib64/
ldd `which openssl`
openssl version
openssl version -a

CentOS6.5下升级openssl-1.1.1g与openssh-8.3p1_源码包_08

CentOS6.5下升级openssl-1.1.1g与openssh-8.3p1_文件拷贝_09

或者如下方式加载库文件

cd /usr/local/openssl/lib
cat /etc/ld.so.conf
echo "/usr/local/openssl/lib" >> /etc/ld.so.conf
ldconfig
ldconfig -v


openssh升级

1、解压openssh的源码包

cd /usr/local/src
cp /root/openssh-8.3p1.tar.gz ./
tar -zxf openssh-8.3p1.tar.gz

CentOS6.5下升级openssl-1.1.1g与openssh-8.3p1_编译安装_10

2、编译安装openssh

cd /usr/local/src/openssh-8.3p1
mv /etc/ssh /etc/ssh_bak
yum install pam pam-devel -y
./configure --prefix=/usr/local/openssh --sysconfdir=/etc/ssh --with-md5-passwords --with-pam --with-ssl-dir=/usr/local/openssl --without-hardening --with-zlib=/usr/local/zlib

make install

CentOS6.5下升级openssl-1.1.1g与openssh-8.3p1_文件拷贝_11

CentOS6.5下升级openssl-1.1.1g与openssh-8.3p1_编译安装_12

CentOS6.5下升级openssl-1.1.1g与openssh-8.3p1_文件拷贝_13

CentOS6.5下升级openssl-1.1.1g与openssh-8.3p1_编译安装_14

3、备份原sshd

which sshd
mv /usr/sbin/sshd /opt/sshd_bak
mv /etc/sysconfig/sshd /opt/sysconfig_sshd
cp /usr/local/openssh/sbin/sshd /usr/sbin/sshd

CentOS6.5下升级openssl-1.1.1g与openssh-8.3p1_文件拷贝_15

4、卸载openssh旧版本,拷贝新版本openssh相关程序与配置文件

rpm -aq | grep openssh
for i in $(rpm -aq | grep openssh); do rpm -e $i --nodeps ; done
mv /etc/ssh/ssh_config.rpmsave /etc/ssh/ssh_config
mv /etc/ssh/sshd_config.rpmsave /etc/ssh/sshd_config
mv /etc/ssh/moduli.rpmsave /etc/ssh/moduli
cd /usr/local/openssh/bin
cp -arf /usr/local/openssh/bin/* /usr/bin/
cp /usr/local/openssh/sbin/sshd /usr/sbin/sshd
cp /usr/local/src/openssh-8.3p1/contrib/redhat/sshd.init /etc/init.d/sshd
chmod a+x /etc/init.d/sshd
cp -a /usr/local/src/openssh-8.3p1/contrib/redhat/sshd.pam /etc/pam.d/sshd.pam
service sshd restart

CentOS6.5下升级openssl-1.1.1g与openssh-8.3p1_文件拷贝_16

CentOS6.5下升级openssl-1.1.1g与openssh-8.3p1_编译安装_17

5、若出现输入了正确的root密码也连不上的情况

在/etc/ssh/sshd_config中加入 PermitRootLogin yes 然后重启sshd服务 

CentOS6.5下升级openssl-1.1.1g与openssh-8.3p1_文件拷贝_18

CentOS6.5下升级openssl-1.1.1g与openssh-8.3p1_编译安装_19

可以看到openssl版本1.1.1g openssh版本8.3p1