centos7制作openssh 7.4p1的rpm包并升级openssh
最近在网上看到说openssh存在巨大安全漏洞,看了下公司centos7的openssh居然还是6.6.1p1,OpenSSH < 7.4版本ssh-agent未对加载的PKCS#11模块进行验证,在实现上存在任意执行代码漏洞,可使攻击者在受影响应用上下文中执行任意代码.好吧,yum上没有openssh的更新,只好自己动手了.
系统:centos 7(64位)
1.准备工作
ssh -V
cd /etc/ssh/
cp sshd_config sshd_config.170117bak--
cd /etc/pam.d
cp sshd sshd.old--
yum install -y gcc gcc-c++ make pam-devel rpm-build rpmdevtools zlib-devel krb5-devel tcp_wrappers tcp_wrappers-devel tcp_wrappers-libs libX11-devel xmkmf libXt-devel wget openssl openssl-devel
mkdir -p rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}
cd ~/rpmbuild/SOURCES
wget http://openbsd.hk/pub/OpenBSD/OpenSSH/portable/openssh-7.4p1.tar.gz
wget http://ftp.riken.jp/Linux/momonga/6/Everything/SOURCES/x11-ssh-askpass-1.2.4.1.tar.gz
2.配置spec文件
cd ~/rpmbuild/SPECS/
tar zxf ../SOURCES/openssh-7.4p1.tar.gz openssh-7.4p1/contrib/redhat/openssh.spec
mv openssh-7.4p1/contrib/redhat/openssh.spec openssh-7.4p1.spec
rm -fr openssh-7.4p1
sed -i -e "s/%define no_gnome_askpass 0/%define no_gnome_askpass 1/g" openssh-7.4p1.spec sed -i -e "s/%define no_x11_askpass 0/%define no_x11_askpass 1/g" openssh-7.4p1.spec sed -i -e "s/BuildPreReq/BuildRequires/g" openssh-7.4p1.spec
3.编译生成rpm
rpmbuild -bb openssh-7.4p1.spec
cd ~/rpmbuild/RPMS/x86_64
4.安装rpm包
yum localinstall openssh-7.4p1-1.x86_64.rpm openssh-server-7.4p1-1.x86_64.rpm openssh-clients-7.4p1-1.x86_64.rpm -y
5.修改配置文件
cd /etc/ssh/
\cp sshd_config.170117bak-- sshd_config
sed -i "37a\SyslogFacility AUTHPRIV" /etc/ssh/sshd_config sed -i "44a\PermitRootLogin yes" /etc/ssh/sshd_config sed -i "77a\ChallengeResponseAuthentication no" /etc/ssh/sshd_config sed -i "88a\GSSAPICleanupCredentials no" /etc/ssh/sshd_config sed -i "112a\UsePrivilegeSeparation sandbox" /etc/ssh/sshd_config
cd /etc/pam.d/
cat sshd
\cp sshd.old-- sshd
6.更改密钥权限
cd /etc/ssh/
chmod 600 ssh_host_*_key
systemctl restart sshd
ssh -V
好了,可以看到openssh已经更新成功了.
sed -i -e "s/%define no_gnome_askpass 0/%define no_gnome_askpass 1/g" openssh-7.4p1.spec
2
sed -i -e "s/%define no_x11_askpass 0/%define no_x11_askpass 1/g" openssh-7.4p1.spec
2
能否解释下为什么要改为1呢?