CentOS7下制作OpenSSH 8.4p1 RPM包
1、准备条件
1)openssh-8.4p1.tar.gz源码包
https://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-8.4p1.tar.gz
2)x11-ssh-askpass-1.2.4.1.tar.gz 源码包
wget https://src.fedoraproject.org/repo/pkgs/openssh/x11-ssh-askpass-1.2.4.1.tar.gz/8f2e41f3f7
2、rpm-build以及编译打包环境搭建
yum install rpm-build zlib-devel openssl-devel gcc perl-devel pam-devel
mkdir -p /root/rpmbuild/SOURCES mkdir -p /root/rpmbuild/SPECS cp /root/openssh-8.4p1.tar.gz /root/rpmbuild/SOURCES/ cp /root/x11-ssh-askpass-1.2.4.1.tar.gz /root/rpmbuild/SOURCES/ tar -zxf openssh-8.4p1.tar.gz -C /opt cp /opt/openssh-8.4p1/contrib/redhat/openssh.spec /root/rpmbuild/SPECS/ chown sshd:sshd /root/rpmbuild/SPECS/openssh.spec
3、修改openssh.spec 并进行打包
vi openssh.spec
将原先openssh.spec中的
%global no_x11_askpass 0
%global no_gnome_askpass 0
修改为
%global no_x11_askpass 1
%global no_gnome_askpass 1
并注释掉#BuildRequires: openssl-devel < 1.1
因为openssl安装的版本都低于1.1
这时就可以rpmbuild打包了
rpmbuild -ba openssh.spec
打包开始和打包完成时的截图如下
4、压缩并下载生成的rpm包
cd /root/rpmbuild/RPMS/x86_64 ll tar -zcvf openssh-8.4p1_rpm_package.tar.gz *.rpm sz openssh-8.4p1_rpm_package.tar.gz
5、升级openssh 8.4p1进行验证
在另外一台CentOS7.6机器上升级openssh版本
升级前的版本openssh7.4p1
1)上传解压openssh-8.4p1_rpm_package.tar.gz
cd /opt tar -zxvf openssh-8.4p1_rpm_package.tar.gz
解压出来的如下4个rpm
openssh-8.4p1-1.el7.x86_64.rpm openssh-clients-8.4p1-1.el7.x86_64.rpm openssh-server-8.4p1-1.el7.x86_64.rpm openssh-debuginfo-8.4p1-1.el7.x86_64.rpm
2)备份配置后rpm -Uvh升级到openssh8.4p1
mkdir /etc/sshconfig_backup cp /etc/ssh/sshd_config /etc/sshconfig_backup/ cp /etc/pam.d/sshd /etc/sshconfig_backup/pam.d_sshd
rpm -Uvh openssh*.rpm进行手动升级
rpm -Uvh openssh*.rpm
3)还原配置文件
cp /etc/sshconfig_backup/sshd_config /etc/ssh/sshd_config cp /etc/sshconfig_backup/pam.d_sshd /etc/pam.d/sshd 并加上PermitRootLogin yes允许root用户登录 sed -i "s/#PermitRootLogin yes/PermitRootLogin yes/g" /etc/ssh/sshd_config cat /etc/ssh/sshd_config | grep PermitRootLogin 删除/etc/ssh/目录下相关key文件,否则重启sshd服务会报错 rm -rf /etc/ssh/ssh_host_* service sshd restart
4)验证openssh版本信息
ssh -V rpm -qa | grep openssh
如下图所示说明升级成功
注意openssh8.4p1 rpm包所使用的openssl为1.0.2k版本