安装编译所需工具包
yum install gcc pam-devel zlib-devel
一、升级原因
7.4以下openssh版本存在严重漏洞:
1.OpenSSH 远程权限提升漏洞(CVE-2016-10010)
2.OpenSSH J-PAKE授权问题漏洞(CVE-2010-4478)
3.Openssh MaxAuthTries限制绕过漏洞(CVE-2015-5600)
OpenSSL>=1.0.1可以不用升级OpenSSL
二、安装telnet服务
1.安装软件
#yum-yinstalltelnet-server*telnet
2.启用telnet服务
#vi/etc/xinetd.d/telnet 将其中disable字段的yes改为no以启用telnet服务 #mv/etc/securetty/etc/securetty.old#允许root用户通过telnet登录 #servicexinetdstart#启动telnet服务 #chkconfigxinetdon#使telnet服务开机启动,避免升级过程中服务器意外重启后无法远程登录系统
3.测试telnet能否正常登入系统
三、升级OpenSSH
1.备份当前openssh
mv/etc/ssh/etc/ssh.old mv/etc/init.d/sshd/etc/init.d/sshd.old
2.卸载当前openssh
#rpm-qa|grepopenssh openssh-clients-5.3p1-104.el6.x86_64 openssh-server-5.3p1-104.el6.x86_64 openssh-5.3p1-104.el6.x86_64 openssh-askpass-5.3p1-104.el6.x86_64 #rpm-e--nodepsopenssh-5.3p1-104.el6.x86_64 #rpm-e--nodepsopenssh-server-5.3p1-104.el6.x86_64 #rpm-e--nodepsopenssh-clients-5.3p1-104.el6.x86_64 #rpm-e--nodepsopenssh-askpass-5.3p1-104.el6.x86_64 #rpm-qa|grepopenssh 注意:卸载过程中如果出现以下错误 [root@node1openssh-7.5p1]#rpm-e--nodepsopenssh-server-5.3p1-104.el6.x86_64 errorreadinginformationonservicesshd:Nosuchfileordirectory error:%preun(openssh-server-5.3p1-104.el6.x86_64)scriptletFailed,exitstatus1 解决方法: #rpm-e--noscriptsopenssh-server-5.3p1-104.el6.x86_64
3.openssh安装前环境配置
#install-v-m700-d/var/lib/sshd #chown-vroot:sys/var/lib/sshd 当前系统sshd用户已经存在的话以下不用操作 #groupadd-g50sshd #useradd-c'sshdPrivSep'-d/var/lib/sshd-gsshd-s/bin/false-u50sshd
4.解压openssh_7.5p1源码并编译安装
#tar-zxvfopenssh-7.5p1.tar.gz #cdopenssh-7.5p1 #./configure--prefix=/usr--sysconfdir=/etc/ssh--with-md5-passwords--with-pam--with-zlib--with-openssl-includes=/usr--with-privsep-path=/var/lib/sshd #make #makeinstall
5.openssh安装后环境配置
#在openssh编译目录执行如下命令 #install-v-m755contrib/ssh-copy-id/usr/bin #install-v-m644contrib/ssh-copy-id.1/usr/share/man/man1 #install-v-m755-d/usr/share/doc/openssh-7.5p1 #install-v-m644INSTALLLICENCEOVERVIEWREADME*/usr/share/doc/openssh-7.5p1 #ssh-V#验证是否升级成功
6.启用OpenSSH服务
#在openssh编译目录执行如下目录 #echo'X11Forwardingyes'>>/etc/ssh/sshd_config #echo"PermitRootLoginyes">>/etc/ssh/sshd_config#允许root用户通过ssh登录 #cp-pcontrib/redhat/sshd.init/etc/init.d/sshd #chmod+x/etc/init.d/sshd #chkconfig--addsshd #chkconfigsshdon #chkconfig--listsshd #servicesshdrestart
注意:如果升级操作一直是在ssh远程会话中进行的,上述sshd服务重启命令可能导致会话断开并无法使用ssh再行登入(即ssh未能成功重启),此时需要通过telnet登入再执行sshd服务重启命令。
7.重启系统验证没问题后关闭telnet服务
#mv/etc/securetty.old/etc/securetty #chkconfigxinetdoff #servicexinetdstop 如需还原之前的ssh配置信息,可直接删除升级后的配置信息,恢复备份。 #rm-rf/etc/ssh #mv/etc/ssh.old/etc/ssh原文链接:https://www.f2er.com/centos/377673.html