CentOS 7离线升级openssl和openssh
仅个人学习分享
相关依赖包
pam-1.1.8-23.el7.x86_64.rpm
pam-devel-1.1.8-23.el7.x86_64.rpm
zlib-1.2.7-18.el7.x86_64.rpm
zlib-devel-1.2.7-18.el7.x86_64.rpm
openssl-devel-1.0.2k-19.el7.x86_64.rpm
openssl1.1.1h.tar.gz
openssh8.4p1.tar.gz
zlib-1.2.11.tar.gz
下载地址:
openssl*.tar.gz:https://www.openssl.org/source/
openssh*.tar.gz:https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/
zlib-*.tar.gz:http://www.zlib.net/
rpm包下载地址
http://rpmfind.net/linux/rpm2html/search.php?query=rpm
搜索条件:
1、关闭SELINUX
查看SELinux状态:
1、/usr/sbin/sestatus -v ##如果SELinux status参数为enabled即为开启状态
SELinux status: enabled
2、getenforce ##也可以用这个命令检查
关闭SELinux:
1、临时关闭(不用重启机器):
setenforce 0 ##设置SELinux 成为permissive模式
##setenforce 1 设置SELinux 成为enforcing模式
2、修改配置文件需要重启机器:
修改/etc/selinux/config 文件
将SELINUX=enforcing改为SELINUX=disabled
重启机器即可
2、升级openssl
查看openssl版本和包
openssl version
rpm -qa | grep openssl
卸载openssl包
rpm -e `rpm -qa | grep openssl` --nodeps
安装依赖包
rpm -ivh pam-1.1.8-23.el7.x86_64.rpm --force --nodeps
rpm -ivh pam-devel-1.1.8-23.el7.x86_64.rpm --force --nodeps
rpm -ivh zlib-1.2.7-18.el7.x86_64.rpm --force --nodeps
rpm -ivh zlib-devel-1.2.7-18.el7.x86_64.rpm --force --nodeps
rpm -ivh openssl-devel-1.0.2k-19.el7.x86_64.rpm --force --nodeps
安装zlib
tar -zxvf zlib-*.tar.gz
cd zlib-*
./configure
make
make install
编译安装
tar -zxvf openssl*
cd openssl*/
./config --prefix=/usr/local/ssl --shared
make
make install
echo "/usr/local/ssl/lib" >> /etc/ld.so.conf
ldconfig -v
#注意.1.1是当前安装版本
cp -f /usr/local/ssl/lib/libssl.so.1.1 /usr/lib64
cp -f /usr/local/ssl/lib/libcrypto.so.1.1 /usr/lib64
chmod 555 /usr/lib64/libssl.so.1.1
chmod 555 /usr/lib64/libcrypto.so.1.1
ln -bs /usr/lib64/libcrypto.so.1.1 /usr/lib64/libcrypto.so.11
ln -bs /usr/lib64/libssl.so.1.1 /usr/lib64/libssl.so.11
ln -bs /usr/lib64/libcrypto.so.1.1 /usr/lib64/libcrypto.so
ln -bs /usr/lib64/libssl.so.1.1 /usr/lib64/libssl.so
ln -bs /usr/local/ssl/bin/openssl /usr/bin/openssl
ln -bs /usr/local/ssl/include/openssl /usr/include/openssl
查看openssl版本
openssl version
3、升级openssh
备份openssh
mkdir /etc/ssh/bak
cp /etc/ssh/ssh* /etc/ssh/bak && cp /etc/ssh/m* /etc/ssh/bak
cp /etc/pam.d/sshd ~ #备份/etc/pam.d/sshd。
卸载openssh包
rpm -e `rpm -qa | grep openssh` --nodeps
升级openssh
chmod 600 /etc/ssh/ssh_host_rsa_key
chmod 600 /etc/ssh/ssh_host_ecdsa_key
chmod 600 /etc/ssh/ssh_host_ed25519_key
tar -zxvf openssh*
cd openssh*/
./configure --prefix=/usr --sysconfdir=/etc/ssh --with-pam --with-ssl-dir=/usr/local/ssl --with-md5-passwords --mandir=/usr/share/man
make
make install
安装完成,执行配置
#恢复/etc/pam.d/sshd
mv ~/sshd /etc/pam.d/sshd
cp -p contrib/redhat/sshd.init /etc/init.d/sshd
chmod +x /etc/init.d/sshd
chkconfig --add sshd
chkconfig sshd on
chkconfig --list sshd
编辑/etc/ssh/sshd_config
PermitRootLogin yes
UseLogin yes
UsePam yes || UsePAM yes
重启服务
rm -rf /usr/lib/systemd/system/sshd.service
systemctl daemon-reload
systemctl restart sshd
systemctl status sshd