环境说明
系统环境:centos 6.5 x64 openssh-5.3p1
升级原因:低版本openssh存在漏洞
升级目标:openssh-7.9p1

检查环境
官方文档中提到的先决条件openssh安装依赖zlib1.1.4并且openssl>=1.0.1版本就可以了。

当前版本正好符合openssh7.9p1的安装条件,而且zlib也符合OpenSSH7.9P1的依赖,可以进行直接安装:
[root@noway11 ~]# openssl version
OpenSSL 1.0.1e-fips 11 Feb 2013
[root@noway11 ~]# rpm -q zlib
zlib-1.2.3-29.el6.x86_64
[root@noway11 ~]# rpm -q zlib-devel
zlib-devel-1.2.3-29.el6.x86_64

开启telnet-server服务
为防止openssh升级过程中断开连接,最好开启telnet-server服务以防万一
[root@noway11 ~]yum -y install telnet-server*
[root@noway11 ~]service iptables stop
[root@noway11 ~]chkconfig iptables off
[root@noway11 ~]sed -i 's/\(.*\)disable\(.*\)/\ \ \ \ \ \ \ \ disable\ \ \ \ \ \ \ \ \ =\ no/g' /etc/xinetd.d/telnet ##将其中disable字段的yes改为no以启用telnet服务
[root@noway11 ~]mv /etc/securetty /etc/securetty.old #允许root用户通过telnet登录
[root@noway11 ~]service xinetd start
[root@noway11 ~]chkconfig xinetd on

openssh-7.9p1升级
[root@noway11 ~]yum install -y gcc openssl-devel pam-devel rpm-build pam-devel
[root@noway11 ~]#wget http://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-7.9p1.tar.gz #或者从官网下载,上传至服务器
[root@noway11 ~]rpm -e `rpm -qa | grep openssh` --nodeps
[root@noway11 ~]cd /usr/local/src/ && tar zxvf openssh-7.9p1_Compile.tar.gz && cd openssh-7.9p1
[root@noway11 ~]./configure --prefix=/usr --sysconfdir=/etc/ssh --with-pam --with-zlib --with-md5-passwords --with-tcp-wrappers && make && make install
[root@noway11 ~]sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin\ yes/g' /etc/ssh/sshd_config #或手动修改PermitRootLogin no 修改为 PermitRootLogin yes 允许root远程登陆
[root@noway11 ~]sed -i 's/#PermitEmptyPasswords\(.*\)/PermitEmptyPasswords\ no/g' /etc/ssh/sshd_config ##禁止空密码
[root@noway11 ~]sed -i 's/^SELINUX\(.*\)/SELINUX=disabled/g' /etc/selinux/config ##重点来了~~~禁止selinux 否则重启后会登录失败
[root@noway11 ~]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支持的算法
[root@noway11 ~]cp contrib/redhat/sshd.init /etc/init.d/sshd
[root@noway11 ~]chkconfig --add sshd
[root@noway11 ~]chkconfig sshd on
[root@noway11 ~]service sshd start
[root@noway11 ~]service sshd restart
[root@noway11 ~]chkconfig --list sshd
[root@noway11 ~]ssh -V

关闭telnet-server服务
升级完成,通过ssh可以远程到服务器后,可以关闭telnet-server服务
[root@noway11 ~]mv /etc/securetty.old /etc/securetty #允许root用户通过telnet登录
[root@noway11 ~]service xinetd stop
[root@noway11 ~]chkconfig xinetd off
[root@noway11 ~]service iptables start
[root@noway11 ~]chkconfig iptables on
将之前改过的disable=yes又改回去成no.
随后再将修改iptables将23端口关闭,并重启iptables服务.
至此,可以再开ssh登录,用ssh -V查看版本号

启动报错问题

sshd启动报错:Bad SSH2 KexAlgorithms '...'

查询支持的算法:
[user@localhost ~]# ssh -Q kex
diffie-hellman-group1-sha1
diffie-hellman-group14-sha1
diffie-hellman-group14-sha256
diffie-hellman-group16-sha512
diffie-hellman-group18-sha512
diffie-hellman-group-exchange-sha1
diffie-hellman-group-exchange-sha256
ecdh-sha2-nistp256
ecdh-sha2-nistp384
ecdh-sha2-nistp521
curve25519-sha256
curve25519-sha256@libssh.org
也可以用paste -s -d,直接将查询结果串接并写入配置文件:

echo 'KexAlgorithms' `ssh -Q kex | paste -d, -s` >> /etc/ssh/sshd_config

报错排查技巧
遇到错误,服务端日志必须是首选检查点。
可借助sshd -d启用debug模式来排查问题。
可以用ssh -vvv以便更快找到问题。

更多报错处理方法可以参考:https://segmentfault.com/a/1190000018629266

centos6.5升级openssh至7.9p1的更多相关文章

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

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

  2. Centos6.5升级openssh、OpenSSL和wget

    1.OpenSSL 1.1.查看版本 使用如下命令查看版本: openssl version 1.2.安装gcc依赖 yum -y install gcc gcc-c++ 1.3.安装配置 ./con ...

  3. centos6升级openssh至7.9

    1.为了防止升级失败登陆不了,所以需要安装telnet mkdir /root/ssh_updateyum install -y telnet-serveryum install -y xinetd ...

  4. CentOS6、7升级Openssh至7.9

    出于安全考虑,定期使用Nessus对服务器进行扫描,最新Nessus提示服务器的SSH版本有漏洞,所以把SSH升级到最新版本 1.为了防止升级失败登陆不了,所以需要安装telnet mkdir /ro ...

  5. Centos6.5 离线 Openssh 升级

    目录 OpenSSH 升级 一.基于 Dropbear 设置备用 ssh 服务器 二. Openssh 更新 2.1 ssh配置 备份 2.2 openssh 升级 Openssl 升级(由于Open ...

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

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

  7. CentOS6.5升级为CentOS7.0

    CentOS6.5升级为CentOS7.0 CentOS6.5升级为CentOS7 升级前: [root@localhost ~]# cat /proc/version  Linux version ...

  8. centos升级openssh的两种方式

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

  9. linux升级openssh到7.9

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

随机推荐

  1. 3-STM32物联网开发WIFI(ESP8266)+GPRS(Air202)系统方案升级篇(HTTP介绍,TCP实现HTTP下载文件)

    https://www.cnblogs.com/yangfengwu/p/10357564.html 看了好多文章.....唉,还是自己亲自动手用网络监控软件测试吧 先看这个节安装WEB服务器.... ...

  2. 超级好用的excel导出方法,比phpexcel快n倍,并且无乱码

    public function exportToExcel($filename, $tileArray=[], $dataArray=[]){ ini_set('memory_limit','512M ...

  3. sdcf day1 qwq比赛题解

    目录 写在前面 A 链接 思路 代码 B 链接 翻译 思路 代码 C 链接 翻译 思路 代码 写在前面 来到夏令营的第一场比赛,全是水题(第一题除外,不过是原题还是之前做过的,而且是并查集的果题,咕咕 ...

  4. Pytest权威教程(官方教程翻译)

    Pytest权威教程01-安装及入门 Pytest权威教程02-Pytest 使用及调用方法 Pytest权威教程03-原有TestSuite的执行方法 Pytest权威教程04-断言的编写和报告 P ...

  5. Linux下的nexus数据迁移

    刚到公司没多久,目前公司有两个项目公用一个nexus的maven私服,现在想把两个私服的jar包拆分开: 我在原私服的nexus服务器中, 1.备份原nexus使用命令 完成tar包的压缩 打包完毕后 ...

  6. OpenFOAM——运动和静止的同心圆柱之间的流动(库埃特流)

    本算例来自<ANSYS Fluid Dynamics Verification Manual>中的VMFL001: Flow Between Rotating and Stationary ...

  7. iOS9 TableView和ScrollView滚动不响应问题

    今天开始适配iOS9,发现在有UITableView或是ScrollView的界面滚动不灵敏有些卡顿,研究了下是因为tableview的cell里有可以相应点击事件的Button,当我点击到Butto ...

  8. Scala函数柯里化(Currying or Curry)

    柯里化(Currying) 把接受多个参数的函数变换成接受一个单一参数(最初函数的第一个参数)的函数,并且返回接受余下的参数而且返回结果的新函数的技术. 简单的实现如下: scala> def ...

  9. pyqt5设置背景图片出现问题

    在使用pyqt5时,用qtdesign设置好背景图片,如何设置自行百度,预览没问题,用ptuic5转换为代码却发现显示不了: 首先:我在qtdesign中导入的是pic.qrc,但是转换的代码最后一句 ...

  10. @Conditional 和 @ConditionalOnProperty

    @ConditionalOnProperty https://blog.csdn.net/dalangzhonghangxing/article/details/78420057 @Condition ...