centos6.5升级openssh至7.9p1
环境说明
系统环境: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的更多相关文章
- Centos6.5升级openssh至7.4版本
一,备份配置文件,以备升级失败进行回退 二,下载安装包 wget http://www.zlib.net/zlib-1.2.11.tar.gz wget https://openbsd.mirror. ...
- Centos6.5升级openssh、OpenSSL和wget
1.OpenSSL 1.1.查看版本 使用如下命令查看版本: openssl version 1.2.安装gcc依赖 yum -y install gcc gcc-c++ 1.3.安装配置 ./con ...
- centos6升级openssh至7.9
1.为了防止升级失败登陆不了,所以需要安装telnet mkdir /root/ssh_updateyum install -y telnet-serveryum install -y xinetd ...
- CentOS6、7升级Openssh至7.9
出于安全考虑,定期使用Nessus对服务器进行扫描,最新Nessus提示服务器的SSH版本有漏洞,所以把SSH升级到最新版本 1.为了防止升级失败登陆不了,所以需要安装telnet mkdir /ro ...
- Centos6.5 离线 Openssh 升级
目录 OpenSSH 升级 一.基于 Dropbear 设置备用 ssh 服务器 二. Openssh 更新 2.1 ssh配置 备份 2.2 openssh 升级 Openssl 升级(由于Open ...
- CentOS 6.9 升级OpenSSH版本 关闭ssh服务后门
最近用低版本的OpenSSH(5.9p1版本) 的漏洞给系统留了个后门 , 可以劫持root密码或者给root开启后门密码 : 利用Openssh后门 劫持root密码 如果公司还在用CentOS6的 ...
- CentOS6.5升级为CentOS7.0
CentOS6.5升级为CentOS7.0 CentOS6.5升级为CentOS7 升级前: [root@localhost ~]# cat /proc/version Linux version ...
- centos升级openssh的两种方式
此文介绍的是服务器在有网络和无网络情况下升级openssh方式. 一.首先介绍一个无网络如何升级: 1.准备相关的包 openssh下载地址: http://mirror.internode.on. ...
- linux升级openssh到7.9
客户linux主机ssh存在高危漏洞,需要进行升级修复. linux联网后,直接命令行: [root@gw ~]# yum update openssl -y 此命令只是小版本的升级,比如将opens ...
随机推荐
- C++之Lambda研究
目录 目录 1 1. 前言 1 2. 示例1 1 3. 示例2 2 4. 示例3 3 5. 示例4 3 6. 示例5 6 7. 匿名类规则 6 8. 参考资料 7 1. 前言 本文代码测试环境为“GC ...
- GoCN每日新闻(2019-10-15)
GoCN每日新闻(2019-10-15) GoCN每日新闻(2019-10-15) 1. Go Module 存在的意义与解决的问题 https://www.ardanlabs.com/blog/20 ...
- Error:gradle-resources-test:thymeleaf-in-action.main: java.lang.NoClassDefFoundError: org/apache/tools/ant/util/ReaderInputStream
目录 Error:gradle-resources-test:thymeleaf-in-action.main: java.lang.NoClassDefFoundError: org/apache/ ...
- es6学习3:promise
promise含义: 所谓Promise,简单说就是一个容器,里面保存着某个未来才会结束的事件(通常是一个异步操作)的结果. 从语法上说,Promise 是一个对象,从它可以获取异步操作的消息.Pro ...
- 东软HIS系统_打印发票提示“打印机报错!对访问XXX的设置无效”解决办法
发票打印报错 添加打印机,端口跟物理打印机同一个. 添加 MZJSFP,ZYJSFP,YJJFP三个打印机 打印发票错位 设置自定义纸张 MZJSFP 宽30.40CM 高12.94CM ZYJSFP ...
- CentOS 7 安装 MySql8.0
1-配置 Yum 库 rpm -Uvh https://repo.mysql.com/mysql80-community-release-el7-3.noarch.rpm 2-安装 MySql 2.1 ...
- MariaDB主从复制虚拟机实战
MariaDB简介: MariaDB数据库管理系统是MySQL的一个分支,主要由开源社区在维护,采用GPL授权许可 MariaDB的目的是完全兼容MySQL,包括API和命令行,使之能轻松成为MySQ ...
- .Net Core NOPI操作word(一)
NOPI使用方式 1.安装nuget包 即可使用 Install-Package NPOI 一.创建word文档 //创建生成word文档 string path = "D:\\test.d ...
- Redis 密码设置 及 带密码访问
转: Redis 密码设置 如果不加密码,默认只能本机访问,加密码也是为了安全考虑 1.进入Redis 的安装目录,找到redis.conf文件.用vi命令打开文件 输入 / requirepass ...
- 论consul正确的关闭姿势
最近在工作中发现一个有意思的现象,我用 ctrl+c 关闭本地 consul 的时候,报警系统并没有发出告警,说我的 node 异常,自己看了一下代码,发现 consul 的关闭还是有点猫腻的,仔细来 ...