此文档主要修复漏洞扫描中出现的OPENSSL、OPENSSH等一系列安全问题。升级所需的安装程序不能低于下列安装程序的版本。
第一步 准备安装包
将所需安装包上传到服务器
zlib-1.2.8.tar.gz
http://zlib.net/zlib-1.2.8.tar.gz
openssl-1.0.1.tar.gz
ftp://ftp.openssl.org/source/openssl-1.0.2.tar.gz
openssh-6.6p1.tar.gz
http://mirror.aarnet.edu.au/pub/OpenBSD/OpenSSH/portable/openssh-6.7p1.tar.gz
已测试成功系统:
CentOS 6.3
Redhat Enterprise Linux 5
第二步 确定环境和必要条件
确定SELINUX=disabled
修改/etc/selinux/config 文件
将SELINUX=enforcing改为SELINUX=disabled
确定可以使用本地登录该系统。如不能本地操作,需安装telnet远程服务,防止SSH因配置错误导致服务器无法连接。
拷贝安装包到/opt目录下
第三步 程序升级
1、停止SSHD服务
# /sbin/service sshd stop
2、备份启动脚本
# cp /etc/init.d/sshd /root/
3、卸载系统里原有Openssh
# rpm –qa|grep openssh //查询系统原安装的openssh包,全部卸载。
# rpm -e openssh –nodeps
# rpm -e openssh-server –nodeps
# rpm -e openssh-clients –nodeps
# rpm -e openssh-askpass
4、解压安装zlib包:
# tar -zxvf zlib-1.2.8.tar.gz //首先安装zlib库,否则会报zlib.c错误无法进行
# cd zlib-1.2.8
# ./configure(报错提示没有gcc则需安装GCC库,安装方式在下面)
# make
# make install
安装GCC库:
#更新yum源
cd /etc/yum.repos.d/
wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
yum makecache
#安装gcc库
yum –y install gcc
5、解压安装openssl包:
# tar -zxvf openssl-1.0.1g.tar.gz
# cd openssl-1.0.1g
# ./config –prefix=/usr/local/openssl –shared
# make
# make test
# make install
//备份旧的openssl
# mv /usr/bin/openssl /usr/bin/openssl.OFF
# mv /usr/include/openssl /usr/include/openssl.OFF
//该步骤可能提示无文件,忽略即可
# ln -s /usr/local/ssl/bin/openssl /usr/bin/openssl
# ln -s /usr/local/ssl/include/openssl /usr/include/openssl
//移走原先系统自带的openssl,将自己编译产生的新文件进行链接。
6、配置库文件搜索路径
# echo “/usr/local/ssl/lib” >> /etc/ld.so.conf //指定文件搜索路径
# /sbin/ldconfig -v
# openssl version -a
OpenSSL 1.0.1 14 Mar 2012
built on: Fri Mar 16 17:14:50 CST 2012
platform: linux-x86_64
options: bn(64,64) rc4(16x,int) des(idx,cisc,16,int) idea(int) blowfish(idx)
compiler: gcc -fPIC -DOPENSSL_PIC -DZLIB -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -Wa,–noexecstack -m64 -DL_ENDIAN -DTERMIO -O3 -Wall -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM
OPENSSLDIR: “/usr/local/ssl/ssl”
7、解压安装openssh包:
先将/etc/ssh的文件夹备份:
# mv /etc/ssh /etc/ssh_bak
# tar -zxvf openssh-6.6p1.tar.gz
# cd openssh-6.6p1
# ./configure –prefix=/usr –sysconfdir=/etc/ssh –with-zlib –with-ssl-dir=/usr/local/ssl –with-md5-passwords –mandir=/usr/share/man
–without-openssl-header-check
# make
# make install
8、启动调试ssh
# /usr/sbin/sshd -d
debug1: sshd version OpenSSH_5.9p1
debug1: read PEM private key done: type RSA
debug1: private host key: #0 type 1 RSA
debug1: read PEM private key done: type DSA
debug1: private host key: #1 type 2 DSA
debug1: read PEM private key done: type ECDSA
debug1: private host key: #2 type 3 ECDSA
debug1: rexec_argv[0]=’/usr/sbin/sshd’
debug1: rexec_argv[1]=’-d’
Set /proc/self/oom_adj from 0 to -17
debug1: Bind to port 22 on ::.
Bind to port 22 on :: failed: Address already in use.
debug1: Bind to port 22 on 0.0.0.0.
Bind to port 22 on 0.0.0.0 failed: Address already in use.
Cannot bind any address.
此时可以尝试远程ssh进去服务器,如果能连,并查看验证日志信息等确认无误后,科继续一下步骤
9、启动服务
# cp -p contrib/redhat/sshd.init /etc/init.d/sshd
# chmod +x /etc/init.d/sshd
# chkconfig –add sshd
# cp sshd_config /etc/ssh/sshd_config (如提示覆盖,yes回车)
# cp sshd /usr/sbin/sshd (如提示覆盖,yes回车)
10、验证是否成功
service sshd start(必须使用start参数。不要使用restart,会导致SSH连接断开)
ssh -V //如果看到了新的版本号就没问题啦!