一、升级前准备工作

安装openssh过程需gcc,zlib-devel,openssl-devel,等编译环境,如果通过rpm包来安装,需要解决各种依赖包,故配置本地yum源解决依赖问题。

1. 配置本地yum源

[root@localhost cdrom]# mount /dev/cdrom /mnt/cdrom/     #挂载关盘
[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# vi CentOS-Media.repo #配置yum源环境
[c6-media]
name=CentOS-$releasever - Media
baseurl=file:///mnt/cdrom #指定光盘路径
gpgcheck=1
enabled=1
gpgkey=file:///mnt/cdrom/RPM-GPG-KEY-CentOS-6

2. 安装telnet服务

安装telnet服务,防止升级openssh失败,不能远程登录操作系统(安装过程略,可以通过rpm或yum安装)

3.上传 openssh-7.5p1.tar.gz

二、升级openssh

1.升级前备份openssh配置

[root@localhost chu]# mv /etc/ssh /etc/ssh.old
[root@localhost chu]# mv /etc/init.d/sshd /etc/init.d/sshd.old

2.卸载当前openssh

[root@localhost chu]# rpm -qa |grep openssh
openssh-5.3p1-117.el6.x86_64
openssh-server-5.3p1-117.el6.x86_64
[root@localhost chu]# rpm -e --nodeps openssh-5.3p1-117.el6.x86_64
[root@localhost chu]# rpm -e --nodeps openssh-server-5.3p1-117.el6.x86_64
error reading information on service sshd: No such file or directory
error: %preun(openssh-server-5.3p1-117.el6.x86_64) scriptlet failed, exit status 1
卸载 openssh-5.3p1-117.el6.x86_64报错
解决办法:
[root@localhost chu]# rpm -e --noscripts openssh-server-5.3p1-117.el6.x86_64

3.源码编译

在编译源码过程中会多次出现报错问题,可以通过日志查看缺少编译环境,在安装对应包。

1)第一次编译

[root@localhost openssh-7.5p1]# ./configure --prefix=/usr --sysconfdir=/etc/ssh

checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/home/packgates/ssh_pack/openssh-7.5p1':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
报错:缺少gcc

2)安装gcc编译器

[root@localhost openssh-7.5p1]# yum install gcc

3)第二次编译

[root@localhost openssh-7.5p1]# ./configure --prefix=/usr --sysconfdir=/etc/ssh

checking for zlib.h... no
configure: error: *** zlib.h missing - please install first or check config.log ***
报错:缺少zlib-devel

4)安装zlib-devel

[root@localhost openssh-7.5p1]# yum install zlib-devel 

5)第三次编译

[root@localhost openssh-7.5p1]# ./configure --prefix=/usr --sysconfdir=/etc/ssh

checking openssl/opensslv.h presence... no
checking for openssl/opensslv.h... no
configure: error: *** OpenSSL headers missing - please install first or check config.log ***
报错:没有openssl-devel

6)安装openssl-devel

[root@localhost openssh-7.5p1]# yum install openssl-devel

7)第四次编译

[root@localhost openssh-7.5p1]# ./configure --prefix=/usr --sysconfdir=/etc/ssh

......

Host: x86_64-pc-linux-gnu
Compiler: gcc
Compiler flags: -g -O2 -Wall -Wpointer-arith -Wuninitialized -Wsign-compare -Wformat-security -Wno-pointer-sign -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -ftrapv -fno-builtin-memset -fstack-protector-all -fPIE
Preprocessor flags: -D_XOPEN_SOURCE=600 -D_BSD_SOURCE -D_DEFAULT_SOURCE
Linker flags: -Wl,-z,relro -Wl,-z,now -Wl,-z,noexecstack -fstack-protector-all -pie
Libraries: -lcrypto -lrt -ldl -lutil -lz -lcrypt -lresolv
没有报错

8)最后一步 make && make install

[root@localhost openssh-7.5p1]# make && make install

 ......

ssh-keygen: generating new host keys: RSA DSA ECDSA ED25519
/usr/sbin/sshd -t -f /etc/ssh/sshd_config

检查安装结果:

[root@localhost openssh-7.5p1]# ssh -V
OpenSSH_7.5p1, OpenSSL 1.0.1e-fips 11 Feb 2013

安装成功。

4.配置ssh服务

1.复制启动文件到/etc/init.d/目录下并命名sshd

[root@localhost openssh-7.5p1]# cp contrib/redhat/sshd.init /etc/init.d/sshd

2.ssh加入到开机启动

[root@localhost openssh-7.5p1]# chkconfig --add sshd                #ssh加入到开机启动
[root@localhost openssh-7.5p1]# chkconfig --list sshd #检查ssh开机启动状态
sshd 0:off 1:off 2:on 3:on 4:on 5:on 6:off

3.允许root登录ssh

[root@localhost openssh-7.5p1]# vi /etc/ssh/sshd_config
新加一行PermitRootLogin yes

4.重启ssh服务

[root@localhost openssh-7.5p1]# service sshd restart
Stopping sshd: [ OK ]
/sbin/restorecon: lstat(/etc/ssh/ssh_host_key.pub) failed: No such file or directory
Starting sshd: [ OK ]

最后测试,能ssh登录到操作系统,至此升级openssh完成。

其他

在安装openssh前,本想先卸载旧的openssl,安装新的openssl,结果卸载后yum不能使用,只要又重新openssl,过程见如下。

卸载openssl后踩的坑,卸载后yum安装报错。

[root@localhost ssh_pack]# rpm -e --nodeps openssl-1.0.1e-48.el6.x86

[root@localhost ssh_pack]# yum install gcc
There was a problem importing one of the Python modules
required to run yum. The error leading to this problem was: libssl.so.10: cannot open shared object file: No such file or directory Please install a package which provides this module, or
verify that the module is installed correctly. It's possible that the above module doesn't match the
current version of Python, which is:
2.6.6 (r266:84292, Jul 23 2015, 15:22:56)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-11)] If you cannot solve this problem yourself, please go to
the yum faq at:
http://yum.baseurl.org/wiki/Faq

挂载光盘,重新安装openssl

[root@localhost Packages]# rpm -ivh openssl-devel-1.0.1e-48.el6.x86_64.rpm openssl-1.0.1e-48.el6.x86_64.rpm --nodeps --force

ssh登录问题

问题1:crt登录报错(提示信息:Password authentication faild. Please verify that the username and password are correct.)

重启sshd服务后,crt能登录,但是重启过程中报如下错误。

[root@localhost chu]# service sshd restart
Stopping sshd: [ OK ]
/sbin/restorecon: lstat(/etc/ssh/ssh_host_key.pub) failed: No such file or directory
Starting sshd: [ OK ]

解决办法:

[root@localhost ssh]# vi /etc/init.d/sshd          <<-------启动脚本

#               /sbin/restorecon /etc/ssh/ssh_host_key.pub

官方通告(http://www.openssh.com/txt/release-6.9),openssh从7.0以后版本不在对version1.x支持了,相应的RSA1算法也不再支持,编译openssh源码后不会再/etc/ssh目录下生成ssh_host_key.pub文件。在启动脚本中注释掉/etc/ssh/ssh_host_key.pub即可。

问题2:crt不能登录,重启ssh服务,crt登录恢复,重启操作系统后,必须重启ssh服务,ssh登录恢复。

检查开机启动,ssh服务状态,都是正常的

[root@localhost ssh]# chkconfig --list sshd
sshd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@localhost ssh]# service sshd status
sshd (pid 1309) is running...
[root@localhost ssh]# netstat -npl |grep 22
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1309/sshd
tcp 0 0 :::22 :::* LISTEN 1309/sshd

1.通过在本地ssh root@127.0.0.1,报/root/.ssh/known_hosts错误,清空known_hosts文件内容,ssh登录恢复正常。

2.关闭selinux

总结:用ssh登录服务器,ssh会把每个访问服务器的公钥(public key)都记录在/root/.ssh/known_hosts文件中,当下次访问相同服务器时,ssh就会核对公钥。升级openssh后,以前的公钥信息还存在,登录时就会不匹配,因此需要清空以前的公钥,重新生成新的公钥才能重新登录。

linux系统升级openssh的更多相关文章

  1. Linux服务-openssh

    目录 1. 使用 SSH 访问远程命令行 1.1 OpenSSH 简介 1.2 SSH 版本 1.3 SSH 认证方式 1.4 openSSH 的工作模式 1.5 Secure Shell 示例 1. ...

  2. 各系统升级openssh

    修订号: [V1.0] 修订人: [陈土锋] 修订日期: [2019.06.04] 前言 该文档只适用用于服务器Redhat,centos,Ubuntu和suse系统的openssh升级.需要注意必须 ...

  3. Linux系统升级更新openssh 7.3p1

    放在最前面:鉴于网上爬虫猖獗,博客被盗时有发生,这里需要来个链接,大家请认准来自博客园的Scoter:http://www.cnblogs.com/scoter2008,本文将持续更新 最近绿盟给扫描 ...

  4. linux升级openssh到7.9

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

  5. linux之openssh协议

    SSH的全称是Secure Shell,简单说来ssh是一种安全的外壳协议,用于两个计算机间安全的远程登陆,说它安全,是因为ssh采用公钥加密的机制.最开始时用作远程管理的工具是telnet,这个协议 ...

  6. linux升级openssh

    升级sshd到OpenSSH-6.7并删除老版本ssh 1)升级前准备 查看是否缺包 # rpm -qa | egrep "gcc|make|perl|pam|pam-devel" ...

  7. recovery&linux系统升级数据更新分析总结

    先说说对升级的理解吧.系统升级是软件更新及BUG修复的主要方式,升级的主要原理就是数据搬移的过程,把我们需要的数据,从某个地方,更新到另外的一个地方.这个过程就叫做升级.一般是当我们系统有了新的功能增 ...

  8. redhat系统升级openssh到7.5

    注意,注意,注意重要的事情说三遍,关于ssh的升级不能完全按照别人的教程进行升级,因为每台生产机器都是不一样的,有可能别人能升级成功但是另外一个就可能会失败,因为每台机器上面跑的应用是不一样的,涉及到 ...

  9. linux查看openssh和openssl版本

    查看 openssh 版本命令 ssh -V 查看 openssl 版本命令 openssl version

随机推荐

  1. webpack学习笔记二

    sourceMap 源代码与打包后的代码的映射关系.例如,在某个源文件中test.js里面有个错误,如果开启状态,那么打包后运行的报错信息就会说明是错误的具体位置,如果是关闭状态,报错后,提示的报错位 ...

  2. es的调优

    3.1.分片查询方式 当前的图片中有5个主分片,5个副本:这对于es的集群来说,这种配置是非常常见的: 但是问题来了,当我们的客户端做查询的时候,程序会向主分片发送请求还是副本发送请求? 还是说直接去 ...

  3. 【转】vux (scroller)上拉刷新、下拉加载更多

    1)比较关键的地方是要在 scroller 组件上里加一个 ref 属性 <scroller :lockX="true" height="-170" :p ...

  4. Spring 使用RedisTemplate操作Redis

    首先添加依赖: <!-- https://mvnrepository.com/artifact/redis.clients/jedis --> <dependency> < ...

  5. vim输入操作

    在英文状态下按下 键盘上的 ”I“ 使用下箭标移动光标到最下面一行,然后按下END键,按下ENTER键 输入你的内容 按下ESC键,然后输入冒号,即 (:wq) 输入保存流程结束

  6. 微信小程序 input 组件

    输入框:该组件是原生组件,使用的时候要注意相关的设置 属性: value:类型 字符串 输入框的初始内容 type:类型 字符串 input类型 属性值:text 文本输入键盘 number 数字输入 ...

  7. ffmpeg 文件推流 rtsp和rtmp

    // rtsp推流  /opt/srs/srs2 ./objs/ffmpeg/bin/ffmpeg -re -i /root/mp4/1.mp4 -vcodec copy -codec copy -f ...

  8. 认识了一个新的手机游戏剖析工具- SnapDragon Profiler

    原来这个是高通的工具,具说UNITY官方推荐了这个工具.大概看了下,可以从宏观上实时剖析手机应用的方方面面

  9. JS text节点无innerHTML

    在线预览 text节点无innerHTML这个属性!!! 如果直接修改text节点的属性(data,nodeValue,textContent),或者使用js原生的修改text节点的内容的方法都会将H ...

  10. centos7安装kafka

    1.官网或 wget 下载 kafka_2.12-2.2.0.tgz 二进制代码包 cd /home/tar wget http://mirror.bit.edu.cn/apache/kafka/2. ...