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 ...
随机推荐
- 洛谷 P2897 【蚯蚓】 题解
先分析一下题意: 这个题说的就是一开始给你很多条蚯蚓,然后给出你规定的次数,每一次都从蚯蚓里面拿出最长的来切成一条是原来q倍的,另一条是原来的(1 - q)倍,把切开的两条再放回去.规定次数完成之后, ...
- kafka-python 1.4.6 版本触发的一个 rebalance 问题
在使用了最新版的 kafka-python 1.4.6 在 broker 对 topic 进行默认配置的情况下报出类似错误 CommitFailedError CommitFailedError: C ...
- 微信小程序之使用checkbox
效果图如下: 实例代码如下:type_add.js // pages/detail_add/detail_add.js Page({ /** * 页面的初始数据 */ data: { selectDa ...
- python简单的游戏场景代码
模拟英雄联盟游戏场景的简单场景 最后计算出英雄的战斗力 class Hero: def __init__(self, na, gen, age, fig): self.name = na self.g ...
- plsql查询数据库-中文显示问号问题
解决方法: 设置本地环境变量 :NLS_LANG=AMERICAN_AMERICA.ZHS16GBK https://blog.csdn.net/github_38358734/article/det ...
- uploadifive 1.1.2 动态传参
之前用过Flash版本的uploadify,写过一篇关于uploadify动态传参的文章(点击打开链接).后来有了HTML5版本的上传控件,叫uploadifive,测试着用了一下,效果还不错.这里主 ...
- Solidity truffle,部署合约到Ropsten测试链或主链,调用合约(转)
Solidity truffle,部署合约到Ropsten测试链或主链,调用合约 转 https://blog.csdn.net/houyanhua1/article/details/89010896 ...
- Android 解读Event和Main Log
1 Android P EventLogTags文件 Android P 9.0.0 所有EventLogTags文件List: system/bt/EventLogTags.logtags syst ...
- 关于H5项目开发中TS(或JS)文件按照顺序编译成一个文件的记录
由于js的执行特性,多个js文件合成一个文件或者进行多个js文件加载时,时需要按照指定的顺序进行的,否则会出现报错的情况. 我们看一下目前几个主流H5引擎的做法. 白鹭的做法 当前版本的做法 在tsc ...
- mac下安装face_recognition
安装依赖库: 1.安装cmake (是一个跨平台的安装工具) brew install cmake 2.安装boost.boost-python(C++的程序库) brew install boost ...