OpenSSH_8.0p1 升级到 OpenSSH_9.3p2
1、系统版本2、OpenSSH版本3、文件备份4、下载升级包5、升级6、验证6.1、版本验证6.2、远程验证6.3、sftp验证
OpenSSH 安全漏洞(CVE-2023-38408)处理,需要将OpenSSH的版本升级到9.3p2,当前服务器为阿里云抢占式的临时服务,系统为基于龙蜥的Alibaba Cloud Linux 3.2104 LTS 64位 等保2.0三级版,可看作是CentOS 系统。
由于这是云上临时服务器,所以不考虑升级失败导致的业务不可用等问题。当升级失败时,重置系统即可。
1、系统版本
本次升级的系统为:Alibaba Cloud Linux 3.2104 LTS 64位 等保2.0三级版(可看作CentOS 7.x/8.x的版本)
2、OpenSSH版本
OpenSSH初始版本为:OpenSSH_8.0p1
3、文件备份
mkdir -p /opt/temp/ssh_update && cd /opt/temp/ssh_update
cp -a /etc/{ssh,pam.d} .
4、下载升级包
下载地址:
# http://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/
# http://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/
wget http://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-9.3p2.tar.gz
tar -zxf openssh-9.3p2.tar.gz && cd openssh-9.3p2
5、升级
# 1、卸载
rpm -e --nodeps `rpm -qa | grep openssh`
# 2、安装依赖
yum -y install gcc pam-devel zlib-devel openssl-devel
# 3、编译配置
./configure --prefix=/usr --sysconfdir=/etc/ssh --with-zlib --with-md5-passwords --with-pam
# 4、编译安装
make && make install
# 5、编译安装会提示:Permissions 0640 for '/etc/ssh/ssh_host_ed25519_key' are too open.
#连带将另外key文件权限也做修改
chmod 600 /etc/ssh/ssh_host_*_key
# 6、编译安装还会提示:It is required that your private key files are NOT accessible by others.
# 可以不用处理
# 7、复制初始化脚本到系统目录
cp -a contrib/redhat/sshd.init /etc/init.d/sshd
# 8、添加可执行权限
chmod u+x /etc/init.d/sshd
# 9、启用开机自启动(System V 系统)
chkconfig --add sshd
chkconfig sshd on
# 10、使用备份的配置文件
# cp -a /opt/temp/ssh_update/ssh/ /etc/ssh/
cp -a /opt/temp/ssh_update/ssh/sshd_config /etc/ssh/
# 11、修改配置文件,其余需要修改的配置可以在启动ssh后,查看相应报错进行修改:journalctl -u sshd -n 50 --no-pager
# 11.1、注释掉:GSSAPIAuthentication yes
# 11.2、注释掉:GSSAPICleanupCredentials no
# 11.3、修改:Subsystem sftp /usr/libexec/openssh/sftp-server为Subsystem sftp internal-sftp
# 11.4、允许 ssh-rsa 算法,OpenSSH 8.8+ 默认禁用 ssh-rsa 签名算法(SHA-1不安全),而客户端仍在使用旧的 RSA 密钥。
# 新增配置:
PubkeyAcceptedAlgorithms +ssh-rsa
HostkeyAlgorithms +ssh-rsa
# 12、替换/etc/pam.d/sshd文件
# 不替换会提示连接报错,解决方式参考:https://blog.csdn.net/avatar_2009/article/details/129665320
cp -a /opt/temp/ssh_update/pam.d/sshd /etc/pam.d/
# 13、启动 SSH 服务
service sshd restart
6、验证
6.1、版本验证
6.2、远程验证
6.3、sftp验证