1.查看现在的版本
# rpm -qa | grep openssh openssh-clients-6.6.1p1-22.el7.x86_64 openssh-server-6.6.1p1-22.el7.x86_64 openssh-6.6.1p1-22.el7.x86_64
2.下载新版本的openssh
cd /usr/src wget http://mirrors.evowise.com/pub/OpenBSD/OpenSSH/portable/openssh-7.4p1.tar.gz tar -xvzf openssh-7.4p1.tar.gz
3.安装辅助包
yum install rpm-build gcc make wget openssl-devel krb5-devel pam-devel libX11-devel xmkmf libXt-devel
4.创建对应目录
mkdir -p /root/rpmbuild/{SOURCES,SPECS} cp ./openssh-7.5p1/contrib/redhat/openssh.spec /root/rpmbuild/SPECS/ cp openssh-7.5p1.tar.gz /root/rpmbuild/SOURCES/ cd /root/rpmbuild/SPECS/
5.修改
sed -i -e "s/%define no_gnome_askpass 0/%define no_gnome_askpass 1/g" openssh.spec sed -i -e "s/%define no_x11_askpass 0/%define no_x11_askpass 1/g" openssh.spec sed -i -e "s/BuildPreReq/BuildRequires/g" openssh.spec
6.build rpm
rpmbuild -bb openssh.spec
7.查看生成的rpm
# cd /root/rpmbuild/RPMS/x86_64/ # ll total 2112 -rw-r--r-- 1 root root 758392 Jun 17 15:27 openssh-7.5p1-1.x86_64.rpm -rw-r--r-- 1 root root 945325 Jun 17 15:27 openssh-clients-7.5p1-1.x86_64.rpm -rw-r--r-- 1 root root 452499 Jun 17 15:27 openssh-server-7.5p1-1.x86_64.rpm
8.升级
# rpm -Uvh *.rpm Preparing... ########################################### [100%] 1:openssh ########################################### [ 33%] 2:openssh-clients ########################################### [ 67%] 3:openssh-server ########################################### [100%]
9.查看
# ssh -V OpenSSH_7.5p1, OpenSSL 1.0.1e-fips 11 Feb 2013 # rpm -qa | grep openssh openssh-clients-7.5p1-1.x86_64 openssh-7.5p1-1.x86_64 openssh-server-7.5p1-1.x86_64