Table of Contents
						
						
	一、背景简介
	  openssh频繁的爆出漏洞,现在的yum源版本都太低,一般是OpenSSH_5.3p1, OpenSSL 1.0.1e-fips 11 Feb 2013,安全性太差,强烈建议去openssh官网下载最新版本进行编译安装升级。
	现以CentOS6.7为例升级openssh版本。
	二、系统环境
	Linux OS:CentOS 6.7 x86_64
	原openssh版本 : OpenSSH_5.3p1, OpenSSL 1.0.1e-fips 11 Feb 2013
	新openssh版本:OpenSSH_7.5p1, OpenSSL 1.0.1e-fips 11 Feb 2013
	iptables关闭    service iptables stop
	selinux关闭    setenforce 0
	三、升级openssh
	#1 安装openssh软件的所需依赖包
	yum -y install telnet telnet-server openssl openssl-devel zlib zlib-devel pam-devel
	#2 配置telnet服务以便于卸载老版本openssh后的远程连接
	sed -r -i -e ‘/disable/ s/yes/no/g’ /etc/xinetd.d/telnet
	## 启动telnet服务
	service xinetd start
	##暂时不退出ssh连接,一般升级的时候不会断开ssh连接,建个Telnet服务只是以防万一。
	#3 卸载就openssh以及相关依赖包和备份sshd_config配置文件
	rpm -e --nodeps --allmatches `rpm -qa|grep openssh`
	\cp -v /etc/ssh/sshd_config /etc/ssh/sshd_config.bak
	#4 官网下载openssh版本7.5p1到/tmp目录
	#5 编译安装openssh7.5p1
	cd /tmp/
	tar zxvf openssh-7.5p1.tar.gz
	cd openssh-7.5p1
		./configure --prefix=/usr --sysconfdir=/etc/ssh --with-md5-passwords --with-pam --with-tcp-wrappers --with-ssl-dir=/usr/local/ssl   --without-hardening
	
	make && make install
	## 复制启动文件到/etc/init.d
	\cp -v contrib/redhat/sshd.init /etc/init.d/sshd
	chmod +x /etc/init.d/sshd
	chkconfig --add sshd
	chkconfig sshd on
	#6 为了安全起见,建议配置不允许root登陆,注意提前建立Linux用户
	[ -n “`grep “^PermitRootLogin” /etc/ssh/sshd_config`” ] && sed -i -r -e ‘/^PermitRootLogin/d’ sshd_config || echo “PermitRootLogin no” >> /etc/ssh/sshd_config
	service sshd start
	四、验证升级后的版本
	[root@S5 /]# ssh -V
	OpenSSH_7.5p1, OpenSSL 1.0.1e-fips 11 Feb 2013
	步骤三的6个小步骤可以直接复制到shell控制台执行,进行ssh的升级,注意从本文拷贝的字符“–”到shell中可能会异常,建议先拷贝到其他文本编辑器里检查无误后再拷贝到shell命令行执行升级。
	(完)






