OpenSSH和OpenSSL升级

需求

centos7.9升级SSH和SSL

OpenSSH升级为openssh9.8

OpenSSL升级为openssl-3.4.0

下载openssh最新版本与openssl对应版本

openssh最新版本下载地址

bash 复制代码
wget https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-9.8p1.tar.gz

OpenSSL下载地址

这里下载的是3.4.0

bash 复制代码
wget https://github.com/openssl/openssl/releases/download/openssl-3.4.0/openssl-3.4.0.tar.gz

Openssl安装

安装前检查

查看Centos系统版本信息

bash 复制代码
cat /etc/redhat-release

查看openssl版本信息

bash 复制代码
openssl version

查看ssh版本信息

bash 复制代码
ssh -V

安装openssl

由于openssh9.8p1要求openssl版本大于等于1.1.1,因此需要升级安装openssl

解压

bash 复制代码
tar xf openssl-3.4.0.tar.gz -C /usr/local/

创建安装目录

bash 复制代码
mkdir /opt/openssl

编译安装

bash 复制代码
# 安装编译工具和prel依赖
yum -y install gcc make perl-IPC-Cmd perl-Data-Dumper
bash 复制代码
# 进入解压目录
cd /usr/local/openssl-3.4.0/
./config  --prefix=/opt/openssl
make && make install 

更新lib文件

检查openssl-3.4.0所需要的函数库

bash 复制代码
ldd /opt/openssl/bin/openssl

添加openssl-3.4.0的库文件路径到ld.so.conf

bash 复制代码
echo "/opt/openssl/lib64" >> /etc/ld.so.conf

更新系统函数库

bash 复制代码
ldconfig  --verbose

查看旧版本的openssl命令路径

bash 复制代码
which openssl

重名为openssl.old

bash 复制代码
 mv /bin/openssl /bin/openssl.old

使用软连接的方式更新openssl命令

bash 复制代码
ln -s /opt/openssl/bin/openssl /bin/openssl

查看openssl版本

bash 复制代码
openssl version

Openssh9.8安装

解压下载的安装包

bash 复制代码
tar xf openssh-9.8p1.tar.gz -C /usr/local/
mv openssh-9.8p1/ openssh

配置解压文件,开始编译

bash 复制代码
yum -y install zlib-devel pam-devel
bash 复制代码
sudo chmod 600 /etc/ssh/ssh_host_rsa_key
sudo chmod 600 /etc/ssh/ssh_host_ecdsa_key
sudo chmod 600 /etc/ssh/ssh_host_ed25519_key
sudo chown root:root /etc/ssh/ssh_host_rsa_key
sudo chown root:root /etc/ssh/ssh_host_ecdsa_key
sudo chown root:root /etc/ssh/ssh_host_ed25519_key
sudo chmod 644 /etc/ssh/sshd_config
bash 复制代码
./configure --prefix=/usr/local/openssh --sysconfdir=/etc/ssh --with-pam --with-ssl-dir=/opt/openssl --with-md5-passwords --mandir=/usr/share/man --with-zlib=/usr/local/zlib --without-hardening
bash 复制代码
make && make install

修改启动sshd,init脚本

从源码目录下复制sshd.init到/etc/init.d/

bash 复制代码
cp /usr/local/openssh/contrib/redhat/sshd.init  /etc/init.d/

查看并修改sshd的新路径,将新的openssh安装路径更新

bash 复制代码
cat /etc/init.d/sshd.init | grep SSHD
sed -i "s/SSHD=\/usr\/sbin\/sshd/SSHD=\/usr\/local\/openssh\/sbin\/sshd/g" /etc/init.d/sshd.init
cat /etc/init.d/sshd.init | grep SSHD

查看并修改ssh-keygen的新路径,将新的ssh-keygen安装路径更新

bash 复制代码
cat -n /etc/init.d/sshd.init | grep ssh-keygen
sed -i "s#/usr/bin/ssh-keygen -A#/usr/local/openssh/bin/ssh-keygen -A#g" /etc/init.d/sshd.init
cat -n /etc/init.d/sshd.init | grep ssh-keygen

启动openssh,并设置开机启动

复制ssh的相关命令

bash 复制代码
cp -arp /usr/local/openssh/bin/* /usr/bin

重启OpenSSH

shell 复制代码
systemctl restart sshd

查看版本

bash 复制代码
ssh -V
shell 复制代码
OpenSSH_9.8p1, OpenSSL 3.4.0 22 Oct 2024
相关推荐
小雪_Snow1 分钟前
CentOS 7 下载教程
centos
你的人类朋友4 分钟前
认识一下Bcrypt哈希算法
后端·安全·程序员
bug攻城狮5 分钟前
CentOS 7 设置静态 IP 地址
linux·tcp/ip·centos
纳切威13 分钟前
CentOS 7部署Zabbix5.0
linux·运维·centos·zabbix
sunshine-sm16 分钟前
CentOS Steam 9安装 MySQL 8
linux·运维·服务器·数据库·mysql·centos·centos stream
bug攻城狮17 分钟前
CentOS 7 快速检查软件包是否已安装的5种方法
linux·运维·centos
sun03224 小时前
使用 javax.net.ssl.HttpsURLConnection 发送 HTTP 请求_以及为了JWT通信选用OSS的Jar的【坑】
http·.net·ssl
Coovally AI模型快速验证4 小时前
基于YOLO集成模型的无人机多光谱风电部件缺陷检测
人工智能·安全·yolo·目标跟踪·无人机
夏天的风996 小时前
本地部署PLM系统,如何用 ZeroNews 实现远程访问?
安全·远程工作
wanhengidc6 小时前
高性价比云手机挑选指南
运维·网络·安全·游戏·智能手机