统信UOS操作系统aarch64 1060e版制作openssh 9.4p1/9.5p1 rpm包 —— 筑梦之路_openssh-9.4p1rpm-优快云博客
最近比较少使用UOS,此处主要记录下UOS x86架构下使用官方源码制作openssh 9.9p1 二进制rpm包的过程。
源码改造和制作rpm包
# 准备源码文件
wget https://src.fedoraproject.org/repo/pkgs/openssh/x11-ssh-askpass-1.2.4.1.tar.gz/8f2e41f3f7eaa8543a2440454637f3c3/x11-ssh-askpass-1.2.4.1.tar.gz
wget https://mirrors.aliyun.com/pub/OpenBSD/OpenSSH/portable/openssh-9.9p1.tar.gz
# 安装依赖包和工具包
yum install rpm-build zlib-devel openssl-devel gcc perl-devel pam-devel xmkmf libXt-devel gtk2-devel make -y
# 初始化rpm制作环境
rpmbuild -ba openssh.spec
# 解压源码进行改造
tar -zxf openssh-9.9p1.tar.gz && cd openssh-9.9p1/contrib/redhat/
openssh.spec文件中
# 将改行注释
#PreReq: initscripts >= 5.00
解决报错:line 94: prereq is deprecated: PreReq: initscripts >= 5.00
# 添加ssh-copy-id命令
## 280行
install -m755 contrib/ssh-copy-id $RPM_BUILD_ROOT/usr/bin/ssh-copy-id
## 386行
%attr(0755,root,root) %{_bindir}/ssh-copy-id
# 显示openssl版本
## 34行注释掉
#%global without_openssl 0
## 217-219行删除
%if %{without_openssl}
218 --without-openssl \
219 %endif
文件拷贝
cp openssh.spec /root/rpmbuild/SPECS
cp sshd.init sshd.init.old
cp sshd.pam sshd.pam.old
# 改造完成后,重新打包
cd /root && tar -cvzf openssh-9.9p1.tar.gz openssh-9.9p1
# 将源码包拷贝到rpmbuild/SOURCES目录下
cp openssh-9.9p1.tar.gz rpmbuild/SOURCES/
cp x11-ssh-askpass-1.2.4.1.tar.gz rpmbuild/SOURCES/
# 制作openssh 9.9p1二进制包和源码包
cd rpmbuild/SPECS && rpmbuild -ba openssh.spec
如何正确安装
# 备份
cp -rp /etc/ssh /etc/ssh_backup
cp -rp /etc/pam.d/sshd /etc/pam.d/sshd
# 配置认证
cat > /etc/pam.d/sshd << EOF
#%PAM-1.0
auth required pam_sepermit.so
auth include password-auth
account required pam_nologin.so
account include password-auth
password include password-auth
## pam_selinux.so close should be the first session rule
session required pam_selinux.so close
session required pam_loginuid.so
## pam_selinux.so open should only be followed by sessions to be executed in the user context
session required pam_selinux.so open env_params
session optional pam_keyinit.so force revoke
session include password-auth
EOF
# 更新升级,只需要3个rpm包,openssh-clients openssh-server openssh
yum localinstall *.rpm && systemctl restart sshd
# 检查验证
rpm -qa | grep openssh
ssh -V
至此,完成,仅供参考。