Linux升级OpenSSH修复高危漏洞

前言:
近期因centos 6.x和Redhat 6.x 默认openssh扫描存在大量漏洞,基于安全考虑,需要将openssh_5.3p1升级为最新版,网上查了很多教程,发现openssh存在大量依赖,不解决依赖问题很难保证其他服务。而openssl又被大量程序依赖。实在是头疼。最后发现一个不破坏各种依赖又可以完美升级的方案。


1. 开启telnet避免无法登陆

1.1 安装telnet服务
yum -y install telnet-server*
1.2  启用telnet
先关闭防火墙,阿里云把23端口加入安全组,否则telnet可能无法连接
service iptables stop
chkconfig iptables off
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. 检查环境
官方给出的文档中提到的先决条件openssh安装依赖zlib1.1.4并且openssl>=1.0.1版本就可以了。那么直接看当前系统的openssl版本是多少,发现自带的openssl版本符合openssh7.9p1的安装条件,自带的zlib也符合OpenSSH7.9P1的依赖。那么就直接安装吧

[root@zabbix-serv ~]# openssl version
OpenSSL 1.0.1e-fips 11 Feb 2013
[root@zabbix-serv ~]# rpm -q zlib
zlib-1.2.3-29.el6.x86_64
[root@zabbix-serv ~]# rpm -q zlib-devel
zlib-devel-1.2.3-29.el6.x86_64
3. 安装相关组件并升级openssh
yum install -y gcc openssl-devel pam-devel rpm-build pam-devel 
wget https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-7.9p1.tar.gz
rpm -e `rpm -qa | grep openssh` --nodeps
tar -zxvf openssh-7.9p1.tar.gz
cd openssh-7.9p1/
./configure --prefix=/usr --sysconfdir=/etc/ssh --with-pam --with-zlib --with-md5-passwords --with-tcp-wrappers && make && make install
sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin\ yes/g' /etc/ssh/sshd_config #或手动修改PermitRootLogin no 修改为 PermitRootLogin yes 允许root远程登陆
sed -i 's/#PermitEmptyPasswords\(.*\)/PermitEmptyPasswords\ no/g' /etc/ssh/sshd_config  ##禁止空密码
sed -i 's/^SELINUX\(.*\)/SELINUX=disabled/g' /etc/selinux/config  ##重点来了~~~禁止selinux 否则重启后会登录失败
echo 'KexAlgorithms curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1' >> /etc/ssh/sshd_config ## 写上新版ssh支持的算法
cp contrib/redhat/sshd.init /etc/init.d/sshd
chkconfig --add sshd
chkconfig sshd on
service sshd start
service sshd restart
chkconfig --list sshd
ssh -V
4. 关闭telnet开启防火墙
mv /etc/securetty.old /etc/securetty   #允许root用户通过telnet登录
service xinetd stop
chkconfig xinetd off
service iptables start
chkconfig iptables on
将之前改过的disable=yes又改回去成no.
随后再将修改iptables将23端口关闭,并重启iptables服务.
至此,可以再开ssh登录,用ssh -V查看版本号.
 
如有必要,可重新开启防火墙
service iptables start
chkconfig iptables on
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值