#漏洞说明#

OpenSSH(OpenBSD Secure Shell)是OpenBSD计划组所维护的一套用于安全访问远程计算机的连接工具。当前低版本(<7.3)的OpenSSH存在用户枚举漏洞。OpenSSH SSH守护进程允许用户进行身份验证时的时间差进行用户枚举,比如使用SHA256或SHA512进行用户密码哈希,用户名不存在时,SSHD会对静态密码使用BLOWFISH哈希,导致远程攻击者利用较长密码响应时间差,确定用户名。

目前厂商已经发布了升级补丁以修复这个安全问题,所以我们需要将我们的OpenSSH升级到7.3+版本。

#升级OpenSSH#

首先来查看下当前的SSH版本:

# which ssh
/usr/bin/ssh
# ssh -V
OpenSSH_5.3p1, OpenSSL 1.0.1e-fips Feb #openssl version -a
OpenSSL 1.0.1e-fips Feb
built on: Wed Mar :: UTC
platform: linux-x86_64

首先备份当前的SSH目录:

# mv /etc/ssh /etc/ssh-bak

下载并安装新版本的OpenSSH,我们这里选择了日本的下载站点,有需要的可以从:http://www.openssh.com/portable.html 中选择合适站点下载:

# cd /usr/local/src
# wget http://ftp.jaist.ac.jp/pub/OpenBSD/OpenSSH/portable/openssh-7.6p1.tar.gz
# tar zxf openssh-.6p1.tar.gz
# cd openssh-.6p1
# ./configure --prefix=/usr/local/openssh-7.6 --sysconfdir=/etc/ssh --with-pam --with-zlib --with-md5-passwords --with-tcp-wrappers
# make
# make install

这个时候安装已经完成,修改配置文件:

# vim /etc/profile
...
export SSH_HOME=/usr/local/openssh-7.6
export PATH=$SSH_HOME/bin:$SSH_HOME/sbin:$PATH # source /etc/profile

再查看当前的SSH版本:

# which ssh
/usr/local/openssh-7.6/bin/ssh
# ssh -V
OpenSSH_7.6p1, OpenSSL 1.0.1e-fips Feb

这个时候命令已经修改成了新的了,继续修改配置文件:

# vim /etc/ssh/sshd_config
...
Port
AddressFamily inet SyslogFacility AUTH PermitRootLogin no PasswordAuthentication yes ChallengeResponseAuthentication no X11Forwarding yes UseDNS no

我们之前备份了SSH的配置文件,这里将HOST KEY文件还原:

# cp /etc/ssh-bak/ssh_host_key /etc/ssh
# cp /etc/ssh-bak/ssh_host_key.pub /etc/ssh

接着修改启动脚本,重新注明新的KEYGEN和SSHD命令的目录:

# vim /etc/init.d/sshd
...
KEYGEN=/usr/local/openssh-7.6/bin/ssh-keygen
SSHD=/usr/local/openssh-7.6/sbin/sshd
...

重启SSH服务:

# service sshd restart
Stopping sshd: [ OK ]
Starting sshd: [ OK ]

最后,将备份的SSH目录删除:

# rm -rf /etc/ssh/ssh-bak

至此,OpenSSH升级完毕。

05-11 19:58