AlmaLinux升级OpenSSH到9.8最新版本
适用于
8
和9
一、备份OpenSSH
1、查看Openssh路径
which ssh
# /usr/bin/ssh
whereis ssh
# ssh: /usr/bin/ssh /etc/ssh /usr/share/man/man1/ssh.1.gz
2、创建备份目录
mkdir -p /backup_ssh
3、 备份SSH配置文件
cp -r /etc/ssh /backup_ssh/ssh_$(date +%Y%m%d%H%M%S)
cp -r /etc/pam.d /backup_ssh/pam.d_$(date +%Y%m%d%H%M%S)
# 备份/etc/ssh和/etc/pam.d,并添加时间戳
4、验证备份
ls -l /backup_ssh
5、恢复备份
如果因安装失误导致配置丢失,需要把配置恢复回去。
cp -r /backup_ssh/ssh_20240905102657/* /etc/ssh/
cp -r /backup_ssh/pam.d_20240905102701/* /etc/pam.d/
sudo systemctl restart sshd
二、下载、安装编译
1、安装源码编译依赖包
yum groupinstall "Development Tools" -y
yum install -y pam-devel openssl-devel zlib zlib-devel tar
2、下载最新的OpenSSH源代码:
wget https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-9.8p1.tar.gz
3、解压、编译
tar -xzf openssh-9.8p1.tar.gz
cd openssh-9.8p1
./configure
make && make install
4、重启SSH服务:
systemctl restart sshd
5、验证版本
ssh -V
# OpenSSH_9.8p1, OpenSSL 3.0.7 1 Nov 2022
which ssh
# /usr/local/bin/ssh
# 安装位置已经更改