环境说明
系统环境: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. Android入门教程(八)

    关注我,每天都有优质技术文章推送,工作,学习累了的时候放松一下自己. 本篇文章同步微信公众号  欢迎大家关注我的微信公众号:「醉翁猫咪」 今天讲讲安卓入门(八),讲讲Android的简介,如何搭建An ...

  2. SQL语句操作数据试题

    1.在SQL Server中,下列关于数据完整性的说法错误的是(). (选择一项) A:实体完整性要求表中的每一行数据都反映不同的试题,不能存在相同的数据行 B:域完整性是只给定列的输入有效性 C:在 ...

  3. 坑:jmeter部署AWS云服务器时出现连接超时Non HTTP response code: org.apache.http.conn.HttpHostConnectException

    背景: jmeter脚本部署到云服务器(AWS EC2)公网上时,启动jmeter脚本运行了5个小时才运行完毕,后面发现脚本报错timeout(如图),找了很久不知道原因,后面进入脚本发现全部在报错. ...

  4. hdu5438 Ponds[DFS,STL vector二维数组]

    目录 题目地址 题干 代码和解释 参考 题目地址 hdu5438 题干 代码和解释 解答本题时参考了一篇代码较短的博客,比较有意思,使用了STL vector二维数组. 可以结合下面的示例代码理解: ...

  5. modao账户

    chairman987@163.com 墨刀注册 p@ssw0rd OR 123456

  6. Linux Shell 之 对文件中的行、单词、字符进行迭代

    在进行文本文件进行处理时,对文件件中的行.单词.字符进行迭代和遍历是非常常用的操作.而将一个简单的循环用于迭代,再加上来自stdin或文件的重定向,这就是对文件中的行.单词.和字符进行迭代的基本方法. ...

  7. C# System.Web.Mail.MailMessage 发邮件

    C# System.Web.Mail.MailMessage 发邮件 新建控制台Console项目,然后添加 System.Web引用 代码如下: using System; using System ...

  8. C# linq 使用Groupby lamda 获取非重复数据

    ).GroupBy(b => b.BasicUserId).Select(a => new MyServicesListViewModel() { HeadIcon = apiUrl + ...

  9. remaining connection slots are reserved for non-replication superuser connections

    使用客户端工具连接pg,连接失败,报错以下错误: FATAL: remaining connection slots are reserved for non-replication superuse ...

  10. Nginx 配置 HTTP 代理

    配置如下 #user nobody; worker_processes 1; #error_log logs/error.log; #error_log logs/error.log notice; ...