# 安装rpm编译环境
yum install -y rpm-build gcc gcc-c++ glibc glibc-devel openssl-devel openssl pcre pcre-devel zlib zlib-devel make wget krb5-devel pam-devel libX11-devel xmkmf libXt-devel initscripts libXt-devel imake gtk2-devel lrzsz --downloadonly --downloaddir=/opt/software/package/rpm-build
rpm -Uvh --force --nodeps /opt/software/package/rpm-build/*.rpm
# 创建几个目录备用
mkdir -pv /root/rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}
# 下载openssh源码包
cd /root/rpmbuild/SOURCES/
wget https://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-9.2p1.tar.gz --no-check-certificate
# 解压源码包
tar -zxvf openssh-9.2p1.tar.gz -C /root/rpmbuild/SPECS/
# 修改相关文件内容(预防编译报错)
cd /root/rpmbuild/SPECS/openssh-9.2p1/contrib/redhat/
sed -i -e "s/%global no_gnome_askpass 0/%global no_gnome_askpass 1/g" openssh.spec
sed -i -e "s/%global no_x11_askpass 0/%global no_x11_askpass 1/g" openssh.spec
sed -i '/openssl-devel < 1.1/s/^/#/' openssh.spec
# 编译打包
rpmbuild -bb /root/rpmbuild/SPECS/openssh-9.2p1/contrib/redhat/openssh.spec
# 如果打包失败,可以卸载重装openssl-devel,再用上面的代码打包:
yum remove -y openssl-devel yum install -y openssl-devel
# 打包成功后就可以安装包了(不是每个包都必须安装)
cd /root/rpmbuild/RPMS/x86_64/ yum -y install openssh-9.2p1-1.el7.x86_64.rpm openssh-clients-9.2p1-1.el7.x86_64.rpm openssh-server-9.2p1-1.el7.x86_64.rpm
标签:LTS,p1,SP1,devel,rpmbuild,openssh,rpm,9.2 From: https://www.cnblogs.com/jianxiaoxiu/p/17152245.html