yum安装编译依赖的组件
yum install -y rpm-build gcc gcc-c++ glibc glibc-devel openssl-devel openssl pcre-devel zlib zlib-devel make wget krb5-devel pam-devel libX11-devel libXt-devel initscripts libXt-devel gtk2-devel lrzsz
建立编译目录
mkdir -pv /root/rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}
源码包下载并修改,迁移到到/root/rpmbuild/SOURCES
wget http://mirror.aarnet.edu.au/pub/OpenBSD/OpenSSH/portable/openssh-9.5p1.tar.gz -O /home/openssh-9.5p1.tar.gz
cd /home && tar -xf openssh-9.5p1.tar.gz && cd openssh-9.5p1/contrib/redhat/
cp -p sshd.pam sshd.pam.old && cp -p sshd.init sshd.init.old
cd ../../..;mv openssh-9.5p1.tar.gz openssh-9.5p1_$(date "+%Y%m%d%H%M%S").tar.gz
tar -cf openssh-9.5p1.tar.gz openssh-9.5p1/
cp openssh-9.5p1.tar.gz /root/rpmbuild/SOURCES/openssh-9.5p1.tar.gz
解压spec编译文件
cd /root/rpmbuild/SOURCES/
tar -xf openssh-9.5p1.tar.gz openssh-9.5p1/contrib/redhat/openssh.spec
mv openssh-9.5p1 /root/rpmbuild/SPECS
不生成askpass包
cd /root/rpmbuild/SPECS/openssh-9.5p1/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
解决openssl-devel < 1.1报错
sed -i '/openssl-devel < 1.1/s/^/#/' openssh.spec
编译openssh源码
rpmbuild -bb /root/rpmbuild/SPECS/openssh-9.5p1/contrib/redhat/openssh.spec
编译最后无报错即编译成功
查看编译的RPM文件
ll /root/rpmbuild/RPMS/aarch64
校验配置文件
sshd -t
校验配置文件,注释掉过期选项
vi /etc/ssh/sshd_config
授权文件
chmod 600 /etc/ssh/ssh_host_*
chown root:root /etc/ssh/ssh_host_*
升级
rpm -Uvh openssh-9.5p1-1.aarch64.rpm openssh-clients-9.5p1-1.aarch64.rpm openssh-server-9.5p1-1.aarch64.rpm
如果升级成功,无需以下操作
其它命令
重启
systemctl restart sshd
查看状态
systemctl status sshd.service
查看版本号
ssh -V
原文链接:https://blog.csdn.net/rzhidong/article/details/134512216