[root@localhost ~]# mkdir -p /usr/src/redhat/{SOURCES,SPECS}
[root@localhost ~]# cd /usr/src/redhat/SOURCES/
[root@localhost ~]# wget http://ftp.riken.jp/Linux/momonga/6/Everything/SOURCES/x11-ssh-askpass-1.2.4.1.tar.gz
[root@localhost ~]# cp x11-ssh-askpass-1.2.4.1.tar.gz /root/rpmbuild/SOURCES/
[root@localhost SOURCES]# wget https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-7.9p1.tar.gz
[root@localhost SOURCES]# tar -zvxf openssh-7.9p1.tar.gz openssh-7.9p1/contrib/redhat/openssh.spec
[root@localhost SOURCES]# mv openssh-7.9p1/contrib/redhat/openssh.spec ../SPECS/
[root@localhost SOURCES]# chown sshd:sshd /usr/src/redhat/SPECS/openssh.spec
[root@localhost SOURCES]# cp /usr/src/redhat/SPECS/openssh.spec /usr/src/redhat/SPECS/openssh.spec_def
[root@localhost SOURCES]# sed -i -e "s/%define no_gnome_askpass 0/%define no_gnome_askpass 1/g" /usr/src/redhat/SPECS/openssh.spec
[root@localhost SOURCES]# sed -i -e "s/%define no_x11_askpass 0/%define no_x11_askpass 1/g" /usr/src/redhat/SPECS/openssh.spec
[root@localhost SOURCES]# mkdir -p ~/rpmbuild/SOURCES/
[root@localhost SOURCES]# cp /usr/src/redhat/SOURCES/openssh-7.9p1.tar.gz ~/rpmbuild/SOURCES/
[root@localhost SOURCES]# cd /usr/src/redhat/SPECS/
[root@localhost SPECS]# rpmbuild -ba openssh.spec
[root@localhost SPECS]# ll /root/rpmbuild/RPMS/x86_64/openssh-*
-rw-r--r-- 1 root root 496204 1月 17 13:31 /root/rpmbuild/RPMS/x86_64/openssh-7.9p1-1.el7.x86_64.rpm
-rw-r--r-- 1 root root 548576 1月 17 13:31 /root/rpmbuild/RPMS/x86_64/openssh-clients-7.9p1-1.el7.x86_64.rpm
-rw-r--r-- 1 root root 2508852 1月 17 13:31 /root/rpmbuild/RPMS/x86_64/openssh-debuginfo-7.9p1-1.el7.x86_64.rpm
-rw-r--r-- 1 root root 391696 1月 17 13:31 /root/rpmbuild/RPMS/x86_64/openssh-server-7.9p1-1.el7.x86_64.rpm
参考:https://blog.csdn.net/qq_42609381/article/details/82855043
# 编译过程遇到的错误:
错误:构建依赖失败: openssl-devel < 1.1 被 openssh-7.9p1-1.el7.x86_64 需要
解决:[root@localhost SPECS]# vim openssh.spec 注释掉 BuildRequires: openssl-devel < 1.1 这一行
错误:configure: error: PAM headers not found
RPM 构建错误: /var/tmp/rpm-tmp.OB3GHI (%build) 退出状态不好
解决: yum install pam-devel
错误:坏文件:/root/rpmbuild/SOURCES/x11-ssh-askpass-1.2.4.1.tar.gz: 没有那个文件或目录
解决:
wget http://ftp.riken.jp/Linux/momonga/6/Everything/SOURCES/x11-ssh-askpass-1.2.4.1.tar.gz
cp x11-ssh-askpass-1.2.4.1.tar.gz /root/rpmbuild/SOURCES/