因客户漏扫扫描出来openssh及openssl存在漏洞,现升级为官方最新版
这里选择编译安装 去官网下载:
openssl-1.0.2o.tar.gz openssh7.7.1zlib-1.2.1wget https://www.openssl.org/source/openssl-1.0.2o.tar.gzwget https://fastly.cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-7.7p1.tar.gzwget http://www.zlib.net/zlib-1.2.11.tar.gz
1.安装zlib
tar xf zlib-1.2.11.tar.gzcd zlib-1.2.11./configure --prefix=/usr/local/zlibmakemake install #这里有一个报错:# 报错: c_zlib.c:25:19: fatal error: zlib.h: No such file or directory# zlib标准安装指导:# /usr/local/src/zlib-1.2.11 # 构建静态库 ./configuremake testmake install# 构建共享库make clean./configure --sharedmake test
2.升级openssl
tar xf openssl-1.0.2o.tar.gzcd openssl-1.0.2o ./config shared zlib #一定要加上shared 参数,要不在安装openssh的时候就无法找到 make make install # 备份原来的openssl mv /usr/bin/openssl /usr/bin/openssl.bak mv /usr/include/openssl /usr/include/openssl.bak # 因为源码安装默认安装的位置是 /usr/local/ssl 需要将创建软链接到系统位置 ln -s /usr/local/ssl/bin/openssl /usr/bin/openssl ln -s /usr/local/ssl/include/openssl /usr/i
提示:在这里分享一个遇到的的报错大坑,导致之后安装openssh的时候make install一直报错如下:
OpenSSL version mismatch. Built against 1000105f, you have 10001060
/etc/ld.so.conf里面是这样写的(不知道什么原因):
cat /etc/id.so.conf include id.so.conf.d/*conf
之前添加lib库的命令是这样的: echo "/usr/local/ssl/lib/" >> /etc/ld.so.conf
后来修改为:echo "/usr/local/ssl/lib" > /etc/ld.so.conf.d/openssl.conf
3.升级openssh
# 到目前为上发现在的openssh的漏洞都是openssh7.4以前的版本。我们当前升级的是openssh7.7p1 # 备份原openssh文件mv /etc/init.d/ssh /etc/init.d/ssh.oldcp -r /etc/ssh /etc/ssh.old # 卸载原opensshapt-get remove openssh-client openssh-servertar xf openssh-7.7p1.tar.gzcd openssh-7.7p1 ./configure --prefix=/usr --sysconfdir=/etc/ssh --with-md5-passwords --with-pam --with-zlib --with-ssl-dir=/usr/local/ssl --with-privsep-path=/var/lib/sshd #需要指定openssl的安装路径 ---------------------------------报错-------------------------------------------# 报错 checking whether OpenSSL's PRNG is internally seeded... yes# configure: error: PAM headers not found# 解决:ubuntu: apt-get install libpam0g-dev centos: yum -y install pam-devel-------------------------------------------------------------------------------- make make install ---------------------------------报错-------------------------------------------------------------------# 报错: Privilege separation user sshd does not existvim /etc/passwdsshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin # 注册名:口令:用户标识号:组标识号:用户名:用户主目录:命令解释程序# /etc/passwd文件是Linux/UNIX安全的关键文件之一.该文件用于用户登录时校验 用户的口令,当然应当仅对root可写.--------------------------------------------------------------------------------------------------------- #可查看当前SSH的版本。ssh -V
#root@oezn121j8Z:~# ssh -V
#OpenSSH_7.7p1, OpenSSL 1.0.2o 27 Mar 2018到此升级工作完成
如果重启没有
/etc/init.d/ssh
则执行
mv /etc/init.d/ssh.old/etc/init.d/ssh