1:简介

最近浙江电信对线上服务器进行漏洞扫描,暴露出原有的openssh有漏洞,建议升级openssh版本;
2:操作环境
Red Hat Enterprise Linux Server release 6.4
3:所需软件包
(1)gcc zlib zlib-devel make pam pam-devel  (升级过程中所需依赖包)
(2)dropbear-2014.66.tar.bz2(代替原有用pm包安装openssh环境)
(3)openssh-6.7.tar.gz(升级的软件包)
4:操作过程
(1)安装dropbear包代替openssh
[root@localhost ~]#tar -xvf dropbear-2014.66.tar.bz2 
[root@localhost ~]# cd dropbear-2014.66
[root@localhost dropbear-2014.66]#./configure --prefix=/usr/local/dropbear
[root@localhost dropbear-2014.66]# make
[root@localhost dropbear-2014.66]#make install
[root@localhost ~]# mkdir /etc/dropbear
[root@localhost ~]#/usr/local/dropbear/bin/dropbearkey -t rsa -s 2048 -f /etc/dropbear/dropbear_rsa_host_key
Generating key, this may take a while...
Public key portion is:
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCCBQJeoEhvNKkoEO3Y43++TOJl6dneodImEqnfyrfeFpjPQatYH5aQTxghO71KptR5pWYitdRarUcBJGw1fKsfhpwa6is6n6/YyQ2VljqFV+2caHSM3MxmPUHx+A6fzBbvw8u9kDFBz22xXKKSeNpmUyzqvXw8xxt2iu24kkvUYfGfxcHUyauFyiwEDBtz3JbfxlNpTO7eggMi0FT1Q8ndpgf2rg1FbflPweYjjuEtJwqEP6z0CHBsK5/KOAeanlhrkGiJ7EtyP19JxLinNWQeenknERA9IOWox928BjE3ZQ8Fa3JqAQg/w9jNNaugTgxedeLxn897DQBe9lgaatwR root@localhost.localdomain
Fingerprint: md5 dd:75:10:cf:a0:0f:19:96:bd:49:69:05:ab:d6:d6:51
[root@localhost ~]# /usr/local/dropbear/sbin/dropbear -p 1213
[root@localhost ~]# netstat -tunlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name  
tcp        0      0 0.0.0.0:111                 0.0.0.0:*                   LISTEN      809/rpcbind        
tcp        0      0 192.168.122.1:53            0.0.0.0:*                   LISTEN      1281/dnsmasq       
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      1651/sshd          
tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN      1123/master        
tcp        0      0 0.0.0.0:1213                0.0.0.0:*                   LISTEN      8037/dropbear      
tcp        0      0 0.0.0.0:40328               0.0.0.0:*                   LISTEN      827/rpc.statd      
tcp        0      0 :::111                      :::*                        LISTEN      809/rpcbind        
tcp        0      0 :::59889                    :::*                        LISTEN      827/rpc.statd      
tcp        0      0 :::22                       :::*                        LISTEN      1651/sshd          
tcp        0      0 ::1:25                      :::*                        LISTEN      1123/master        
tcp        0      0 :::1213                     :::*                        LISTEN      8037/dropbear      
tcp        0      0 :::3306                     :::*                        LISTEN      14315/mysqld       
udp        0      0 0.0.0.0:1003                0.0.0.0:*                               827/rpc.statd      
udp        0      0 0.0.0.0:111                 0.0.0.0:*                               809/rpcbind        
udp        0      0 0.0.0.0:38790               0.0.0.0:*                               827/rpc.statd      
udp        0      0 192.168.122.1:53            0.0.0.0:*                               1281/dnsmasq       
udp        0      0 0.0.0.0:67                  0.0.0.0:*                               1281/dnsmasq       
udp        0      0 0.0.0.0:984                 0.0.0.0:*                               809/rpcbind        
udp        0      0 :::111                      :::*                                    809/rpcbind        
udp        0      0 :::40854                    :::*                                    827/rpc.statd      
udp        0      0 :::984                      :::*                                    809/rpcbind    
注:以上操作,已经做到替代原有的openssh软件,还需要注意的是关闭防火墙;或者放行1213端口,该端口是我们任意指定;
5:dropbear环境测试
操作方法:
登陆别的主机对该主机进行ssh登陆
[root@localhost ~]# ssh -p1213 192.168.10.120
The authenticity of host '192.168.10.120 (192.168.10.120)' can't be established.
RSA key fingerprint is 46:de:1b:14:42:5d:83:56:d6:29:15:13:c2:b2:d6:05.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.10.120' (RSA) to the list of known hosts.
root@192.168.10.120's password:
Last login: Tue Feb  3 10:18:15 2015 from 192.168.10.130
说明:测试主机地址:192.168.10.130,升级主机地址:192.168.10.120
6:升级openssh
(1)操作步骤
[root@localhost ~]# mv /etc/ssh /etc/ssh.bak
[root@localhost ~]# rpm -qa |grep openssh
openssh-server-5.3p1-84.1.el6.x86_64
openssh-5.3p1-84.1.el6.x86_64
openssh-clients-5.3p1-84.1.el6.x86_64
[root@localhost ~]# rpm -e --nodeps `rpm -qa |grep openssh`
[root@localhost ~]# tar -xvf openssh-6.7p1.tar.gz
[root@localhost openssh-6.7p1]# ./configure --prefix=/usr --sysconfdir=/etc/ssh --with-pam --with-zlib --with-md5-passwords
[root@localhost openssh-6.7p1]#make
[root@localhost openssh-6.7p1]#make install
[root@localhost ~]# /usr/sbin/sshd -t -f /etc/ssh/sshd_config
[root@localhost openssh-6.7p1]# ssh -V
OpenSSH_6.7p1, OpenSSL 1.0.0-fips 29 Mar 2010
[root@localhost openssh-6.7p1]# cp contrib/redhat/sshd.init /etc/init.d/sshd
[root@localhost openssh-6.7p1]# /etc/init.d/sshd start
[root@localhost ~]# killall dropbear
[root@localhost ~]# netstat -tunlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name  
tcp        0      0 0.0.0.0:111                 0.0.0.0:*                   LISTEN      809/rpcbind        
tcp        0      0 192.168.122.1:53            0.0.0.0:*                   LISTEN      1281/dnsmasq       
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      20720/sshd         
tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN      1123/master        
tcp        0      0 0.0.0.0:40328               0.0.0.0:*                   LISTEN      827/rpc.statd      
tcp        0      0 :::111                      :::*                        LISTEN      809/rpcbind        
tcp        0      0 :::59889                    :::*                        LISTEN      827/rpc.statd      
tcp        0      0 :::22                       :::*                        LISTEN      20720/sshd         
tcp        0      0 ::1:25                      :::*                        LISTEN      1123/master        
tcp        0      0 :::3306                     :::*                        LISTEN      14315/mysqld       
udp        0      0 0.0.0.0:1003                0.0.0.0:*                               827/rpc.statd      
udp        0      0 0.0.0.0:111                 0.0.0.0:*                               809/rpcbind        
udp        0      0 0.0.0.0:38790               0.0.0.0:*                               827/rpc.statd      
udp        0      0 192.168.122.1:53            0.0.0.0:*                               1281/dnsmasq       
udp        0      0 0.0.0.0:67                  0.0.0.0:*                               1281/dnsmasq       
udp        0      0 0.0.0.0:984                 0.0.0.0:*                               809/rpcbind        
udp        0      0 :::111                      :::*                                    809/rpcbind        
udp        0      0 :::40854                    :::*                                    827/rpc.statd      
udp        0      0 :::984                      :::*                                    809/rpcbind        
[root@localhost openssh-6.7p1]# /etc/init.d/sshd start
/sbin/restorecon:  lstat(/etc/ssh/ssh_host_ecdsa_key.pub) failed:  No such file or directory
Starting sshd:[  OK  ]
[root@localhost openssh-6.7p1]# service sshd start
/sbin/restorecon:  lstat(/etc/ssh/ssh_host_ecdsa_key.pub) failed:  No such file or directory
Starting sshd:[  OK  ]
[root@localhost openssh-6.7p1]# service sshd status
sshd (pid  20720) is running...
[root@localhost openssh-6.7p1]# chkconfig --add sshd
[root@localhost openssh-6.7p1]# chkconfig --list sshd
sshd            0:off   1:off   2:on    3:on    4:on    5:on    6:off
7:考虑到主机之前使用ssh互信,升级完成后原来生成的公钥将会失效,需要采用升级包中的工具重新生成公钥,操作步骤如下:
7.1:生成公私秘钥
[root@oracle openssh-7.1p1]#pwd
/root/openssh-7.1p1
[root@oracle openssh-7.1p1]#./ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:2ErdCAuGntgVI7+Xx76hDrer1obSRVuoEznksksTDJk root@oracle
The key's randomart image is:
+---[RSA 2048]----+
| o. o            |
|E  +.o           |
| o.o=...         |
| +++=ooO.o       |
|. ++.=*oS .      |
|  + ooo+         |
| . +.=o o        |
|  o +ooo o       |
|   o.+=..        |
+----[SHA256]-----+
注:执行这个命令的时候,不需要填写任何的东西,“Enter”就好,完成以后会在“/root/.ssh”目录下生成两个文件id_rsa,id_rsa.pub;
7.2:生成“authorized_keys”文件;
[root@oracle .ssh]#cat id_rsa.pub >> authorized_keys
注:需要互通的主机之间,都想要对方的公钥,相互拷入即可;
7.3:重启sshd服务
service sshd restart
希望渎者多提意见,
联系方式QQ:1486483698
QQ交流群:431392633

redhat6.4升级openssh至6.7的更多相关文章

  1. 升级OpenSSH详细步骤

    由于系统扫描到OpenSSH版本太低,所以需要将其升级到高版本.网上搜罗数个文章,都多多少少有点疏漏.加上自己之前没升级过SSH,参考好几个文章查缺补漏才升级成功,着实废了不少劲儿.所以综合一下前辈们 ...

  2. centos升级openssh的两种方式

    此文介绍的是服务器在有网络和无网络情况下升级openssh方式. 一.首先介绍一个无网络如何升级: 1.准备相关的包 openssh下载地址:  http://mirror.internode.on. ...

  3. CentOS 6.9 升级OpenSSH版本 关闭ssh服务后门

    最近用低版本的OpenSSH(5.9p1版本) 的漏洞给系统留了个后门 , 可以劫持root密码或者给root开启后门密码 : 利用Openssh后门 劫持root密码 如果公司还在用CentOS6的 ...

  4. linux升级openssh到7.9

    客户linux主机ssh存在高危漏洞,需要进行升级修复. linux联网后,直接命令行: [root@gw ~]# yum update openssl -y 此命令只是小版本的升级,比如将opens ...

  5. centos升级openssh版本

    似乎升级就是简单的安装ssh包就行了,没进行其他修改,虚拟机24个中高低漏洞解决 安装最新包: 1.下载:https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/por ...

  6. 升级OPENSSH 和 OPENSSL

    升级OPENSSH 和 OPENSSL   首先安装telnet服务,防止在操作过程中导致ssh远程中断   # 安装Telnetyum install telnet-server -y chkcon ...

  7. Centos6.5升级openssh至7.4版本

    一,备份配置文件,以备升级失败进行回退 二,下载安装包 wget http://www.zlib.net/zlib-1.2.11.tar.gz wget https://openbsd.mirror. ...

  8. CentOS 升级 openSSH

    openSSH作为linux远程连接工具,容易受到攻击,必须更新版本来解决,低版本有如下等漏洞: a. OpenSSH 远程代码执行漏洞(CVE-2016-10009) b.  OpenSSH aut ...

  9. redhat linux6.5升级openssh

    1.下载最新的openssh包 http://www.openssh.com/portable.html#http 2.升级openssh之前要先打开服务器telnet,通过telnet登录服务器,因 ...

随机推荐

  1. WEBUS2.0 In Action - 搜索操作指南 - (2)

    上一篇:WEBUS2.0 In Action - 搜索操作指南(1) | 下一篇:WEBUS2.0 In Action - 搜索操作指南(3) 2. 使用Query Query是所有查询的基类, 它一 ...

  2. session共享,格式json,php不能简单的设置session.serialize_handler=json,目前只有php,wddx(xml),安装扩展后还有igbinary(二进制)

    即使session_save_handler被自己的类或者方法重写,write与read的出入数据都还是被序列化的,而且被session序列化不是一般的序列化...还是不能解解决memcached保存 ...

  3. mysql 概念和逻辑架构

    1.MySQL整体逻辑架构 mysql 数据库的逻辑架构如下图: 第一层,即最上一层,所包含的服务并不是MySQL所独有的技术.它们都是服务于C/S程序或者是这些程序所需要的 :连接处理,身份验证,安 ...

  4. DOJO 如何清空表单

          在Dojo里,清空表单非常简单 在设置好了相关的环境之后,只要设置dom.byId('formid').reset(); / dijit.byId('formid').reset; Jqu ...

  5. 使用服务器端控制AJAX页面缓存

    你知道 response.setHeader("Cache-Control","no-cache"); 这条语句是干什么的吗? 这是用来防止浏览器缓存动态内容生 ...

  6. Spring 框架概述

    ◆简介 目的:解决企业应用开发的复杂性 功能:使用基本的JavaBean代替EJB,并提供了更多的企业应用功能 范围:任何Java应用 Spring 框架是一个分层架构,由 7 个定义良好的模块组成. ...

  7. SmartGit STUDY 2

    The Index The Index is an intermediate cache for preparing a commit. With SmartGit, you can make hea ...

  8. hdu 2897(威佐夫博奕变形)

    题意:容易理解. 分析:当n%(p+q)==0时,先取者必胜,必胜方案:先取q,然后对方去x个,先取者就取(p+q-x)个,最后对方就必须取玩p个, 当n%(p+q)==r(r<=p),先取者必 ...

  9. hdu 2899(数学基础+二分)

    题意:给了你一个函数,然后给了你x的变化范围,让你求出函数的最小值. 分析:它让你求的是函数的最小值,所以我们可以先对函数求导,得到的导数就可以判断函数的单调性了,求出导数后,我们发现如果函数的导数是 ...

  10. 使用异步任务加载网络上json数据并加载到ListView中

    Android中使用网络访问来加载网上的内容,并将其解析出来加载到控件中,是一种很常见的操作.但是Android的UI线程(也就是主线程)中是不允许进行耗时操作的,因为耗时操作会阻塞主线程,影响用户体 ...