OpenEuler20.03如何升级openssl,我遇到的是,升级到高版本后,系统库原有的低版本openssl仍存在,不知道如何解决老版本存在和新版本冲突的问题
别说20.03, openEuler-22.03-lts-sp1都暂无适配计划,详细见:基于openEuler-22.03-lts-sp1将openssl从1.1升级到3.0报错 · Issue #I6MQJY · src-openEuler/openssl - Gitee.com
经过摸索 OpenSSL 1.1.1d 升级到了 OpenSSL 1.1.1f
1、openssl从https://toscode.gitee.com/src-openeuler/openssl/tree/openEuler-20.03-LTS/地址获取
2、安装后,需要给该文件夹增加可读可执行权限
3、安装后在使用yum报错,原因是编译时缺失了一部分内容
4、重新编译:
./config --prefix=/usr/local/openssl shared enable-ssl3 enable-ssl3-method no-zlib
5、虽然安装成功,但是一旦执行yum install openssl openssl-dev 等相关命令后,版本仍会回退到原始版本
还没尝试跨大版本升级
1、基础准备
官方网站下载最新版*.tar.gz安装包:
官方下载地址:http://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/
openssh-9.0p1.tar.gz (注意:要下载p1版,此版为编译安装包)
官方下载地址:/source/index.html
openssl-1.1.1p.tar.gz
官方下载地址: http://www.zlib.net/
zlib-1.2.13.tar.gz
2、系统环境
查看openssl版本(可以看到版本信息和安装位置)
openssl version -a
ssh -V
3、升级openssh步骤
1)、解压升级包
tar xzvf openssh-9.0p1.tar.gz
tar xzvf openssl-1.1.1p.tar.gz
tar xzvf zlib-1.2.13.tar.gz
2)、编译安装zlib
cd zlib-1.2.123
./configure --prefix=/usr/local/zlib
编译zlib出错,请安装gcc yum install gcc
make -j32
make install
echo ‘/usr/local/zlib/lib’ >> /etc/ld.so.conf
ldconfig -v
验证zlib安装是否成功,要包含include、lib、share三个目录
【待确认:升级系统zlib-开始】
确认新版本是否存在
strings /lib64/libz.so.1 |grep “ZLIB*”
cp /usr/local/zlib/libz.so.1.2.13 /usr/lib64/
cd /usr/lib64/
rm -f libz.so.1
ln -s libz.so.1.2.13 libz.so.1
前后对比
确认新版本是否存在
strings /lib64/libz.so.1 |grep “ZLIB*”
【待确认:升级系统zlib-结束】
3)、编译安装openssl
rpm -qa | grep openssl
rpm -e --nodeps xxxxxxxxxx
cd openssl-1.1.1p
centos:./config --prefix=/usr/local/ssl -d shared
欧拉2003LTS:
./config --prefix=/usr/local/ssl shared enable-ssl3 enable-ssl3-method no-zlib
make -j32
make install (时间比较长,切勿打断)
查看编译openssl下libssl.so.1.1动态库是否定义了SSLv3_client_method
cd /usr/local/ssl/lib
nm libssl.so.1.1 | grep SSLv3_client_method
echo ‘/usr/local/ssl/lib’ >> /etc/ld.so.conf
ldconfig -v
删除旧的:rm -f /usr/bin/openssl
创建新的:ln -s /usr/local/ssl/bin/ssl /usr/bin/ssl
chmod -R 755 /usr/local/ssl/bin/ssl
cd /usr/lib64
删除之前软连接:rm -f libcrypto.so.1.1
创建软连接:ln -s /usr/local/ssl/lib/libcrypto.so.1.1 libcrypto.so.1.1
删除之前软连接:rm -f libssl.so.1.1
创建软连接:ln -s /usr/local/ssl/lib/libssl.so.1.1 libssl.so.1.1
再运行下 ldconfig 将/etc/ld.so.conf重载
4)、升级openSSH(通过Telnet登录到服务器,务必)
停止ssh服务
systemctl stop sshd
备份ssh配置文件
cp -r /etc/ssh /etc/ssh.old
查看系统原有openssh包
rpm -qa | grep openssh
根据上面查询出的结果,卸载系统里原有Openssh(一般有三个包,全部卸载)
rpm -e --nodeps xxxxxxxxxx
rpm -e --nodeps openssh-server-7.4p1-21.el7.x86_64
rpm -e --nodeps openssh-7.4p1-21.el7.x86_64
rpm -e --nodeps openssh-clients-7.4p1-21.el7.x86_64
卸载完成后执行rpm -qa | grep openssh,确保没有回显
rpm -qa | grep openssh
5)、安装openssh
cd openssh-9.0p1
./configure --prefix=/usr/local/openssh --with-zlib=/usr/local/zlib --with-ssl-dir=/usr/local/ssl
make -j32
make install
注:当系统为OpenEuler,检查配置项时,发现openssl-header-check检查不一致时,编译时选择忽略时,将默认使用系统老版本的openssl。
6)、sshd_config文件修改
echo ‘PermitRootLogin yes’ >>/usr/local/openssh/etc/sshd_config
echo ‘PubkeyAuthentication yes’ >>/usr/local/openssh/etc/sshd_config
echo ‘PasswordAuthentication yes’ >>/usr/local/openssh/etc/sshd_config
7)、备份原有文件,并将新的配置复制到指定目录
mv /etc/ssh/sshd_config /etc/ssh/sshd_config.bak
cp /usr/local/openssh/etc/sshd_config /etc/ssh/sshd_config
mv /usr/sbin/sshd /usr/sbin/sshd.bak
cp /usr/local/openssh/sbin/sshd /usr/sbin/sshd
mv /usr/bin/ssh /usr/bin/ssh.bak
cp /usr/local/openssh/bin/ssh /usr/bin/ssh
mv /usr/bin/ssh-keygen /usr/bin/ssh-keygen.bak
cp /usr/local/openssh/bin/ssh-keygen /usr/bin/ssh-keygen
mv /etc/ssh/ssh_host_ecdsa_key.pub /etc/ssh/ssh_host_ecdsa_key.pub.bak
cp /usr/local/openssh/etc/ssh_host_ecdsa_key.pub /etc/ssh/ssh_host_ecdsa_key.pub
服务必须开机自启动,因此要进行一些设置
cp -p contrib/redhat/sshd.init /etc/init.d/sshd
chmod +x /etc/init.d/sshd
自启动设置
chkconfig --add sshd
chkconfig sshd on
也可以使用sshd.service方式做自启动
[Unit]
Description=OpenSSH server daemon
Documentation=man:sshd(8) man:sshd_config(5)
After=network.target sshd-keygen.target
Wants=sshd-keygen.target
[Service]
Type=forking
ExecStart=/etc/init.d/sshd start
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure
RestartSec=42s
PrivateTmp=false
[Install]
WantedBy=multi-user.target
重载
systemctl daemon-reload
重启sshd服务
systemctl restart sshd
查看sshd服务状态
systemctl status sshd
验证ssh版本
ssh -V
–重启服务器,测试ssh
reboot
官方没有,需要自己编译打rpm包