客户这里服务器扫出来了openssh漏洞,需要升级一下,记录以备查用

停止sshd                service sshd stop

执行卸载(如果是远程的话最好先把telnet打开,以防升级不成功远程登录不了了,在自己内网的话打不了在yum装一下ssh,无所谓了):

#rpm -e openssh –nodeps
#rpm -e openssh-server –nodeps
#rpm -e openssh-clients –nodeps
#rpm -e openssh-askpass-gnome
#rpm -e openssh-askpass
 

这里卸载之前最好把/etc/init.d/下面的sshd的启动脚本备份一下,等下编译安装完之后我们直接可以使用这个脚本了

安装新的稳定版的ssl

tar -zxvf openssl-1.0.1b.tar.gz

cd openssl-1.0.1b

#./config shared zlib
#make
#make test
#make install
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

配置库文件搜索路径

#echo “/usr/local/ssl/lib” >> /etc/ld.so.conf
#ldconfig -v

查看openssl的版本号,以验正是否安装正确

#openssl version -a
 

下载最新稳定版的openssh

tar -zxvf openssh-6.0p1.tar.gz

cd openssh-6.0p1

#./configure –prefix=/usr –sysconfdir=/etc/ssh –with-pam –with-zlib –with-ssl-dir=/usr/local/ssl –with-md5-passwords –mandir=/usr/share/man
#make
#make install

查看openssh版本号,验正安装结果

# ssh -v
 

启动并验正服务的开启状况

调试启动,如果以下显示均正常,就可以正常启动sshd了。

#/usr/sbin/sshd -d
debug1: sshd version OpenSSH_4.6p1
debug1: private host key: #0 type 0 RSA1
debug1: read PEM private key done: type RSA
debug1: private host key: #1 type 1 RSA
debug1: read PEM private key done: type DSA
debug1: private host key: #2 type 2 DSA
debug1: rexec_argv[0]=’/usr/sbin/sshd’
debug1: rexec_argv[1]=’-d’
socket: Address family not supported by protocol
debug1: Bind to port 22 on 0.0.0.0.
Server listening on 0.0.0.0 port 22.
Generating 768 bit RSA key.
RSA key generation complete.

启动服务

#/usr/sbin/sshd

查看监听端口中是否有22

#netstat -tnlp | grep :22

然后ssh登录测试一下