一、环境:服务器
操做系统: CentOs 6.7ssh
Openssl 版本:openssl-1.0.2h 官网下载地址:http://www.openssl.org/spa
Openssh 版本:openssh-7.8p1 官网下载地址:http://www.openssh.org/操作系统
二、准备工做:rest
1.1、安装依赖包server
yum -y install gcc pam-devel zlib-develip
1.2、查看系统软件当前版本md5
#openssl versionssl
#ssh -V源码
1.3、安装 telnet 服务
本人安装未卸载现有的Openssh 版本,为了后续保障先安装 telnet 服务
1)安装telnet 服务
#yum -y install telnet-server*
2)启用 telnet 服务
关闭防火墙:service iptables stop
vi /etc/xinetd.d/telnet
将其中disable字段的yes改成no以启用telnet服务
mv /etc/securetty /etc/securetty.old //容许root用户经过telnet登陆
service xinetd start //启动telnet服务
chkconfig xinetd on //使telnet服务开机启动,避免升级过程当中服务器意外重 启后没法远程登陆系统
telnet [ip] //新开启一个远程终端以telnet登陆验证是否成功启用
三、升级软件
2.1、升级 Openssl
1)备份当前openssl(无需卸载)
mv /usr/bin/openssl /usr/bin/openssl.old
mv /usr/include/openssl /usr/include/openssl.old
3)解压源码包并安装
tar xf openssl-1.0.2h.tar.gz
cd openssl-1.0.2h/
./config --shared zlib //必须加上--shared,不然编译时会找不到新安装的openssl的库而报错, 默认 安装目录为 /usr/local/ssl/
make
make test //必须执行这一步结果为pass才能继续,不然即便安装完成,ssh也没法使用
make install
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.d/openssl.conf
ldconfig
openssl version -a //查看是否升级成功
2.2、升级 Openssh
1)备份当前openssh (无需卸载当前版本)
mv /etc/init.d/sshd /etc/init.d/sshd.old
mv /etc/ssh /etc/ssh.old
mv /usr/sbin/sshd /usr/sbin/sshd.old
mv /usr/bin/ssh /usr/bin/ssh.old
2)解压并安装
tar xf openssh-7.8p1.tar.gz
cd openssh-7.8p1/
./configure --prefix=/usr/local/openssh --sysconfdir=/etc/ssh --with-pam --with-ssl-dir=/usr/local/ssl --with-md5-passwords --mandir=/usr/share/man --with-zlib
make && make install
3)恢复文件
cp 你的openssh的解压目录/contrib/redhat/sshd.init /etc/init.d/sshd
chmod +x /etc/init.d/sshd
cp /usr/local/openssh/sbin/sshd /usr/sbin/sshd
cp /usr/local/openssh/bin/ssh /usr/bin/
4)重启 sshd
/etc/init.d/sshd restart 或 service sshd start
-----------------到此安装完成------------------------