Linux以RPM方式升级openssh

本文适用于Centos/Redhat 升级前请自行查看openssl是否为1.0.2k

RPM包在文章最后,请自行下载安装

前期准备:

  1. 开启telnet登录

  2. 备份openssh

  3. 备份配置文件/etc/ssh/ 下的所有文件

  4. 备份/etc/pam.d

实施环节:

一丶配置telnet登录

  1. 安装telnet-server、xinetd

    ​
    yum -y install telnet telnet-server
    yum -y install xinetd
    
    ​

  2. 启用telnet和xinetd

    systemctl enable xinetd
    systemctl enable telnet.socket 
    systemctl start telnet.socket 
    systemctl start xinetd.service 

  3. 配置telnet终端

    vim /etc/securetty
    #行尾添加
    pts/0
    pts/1
    pts/2
    pts/3

  4. 关闭防火墙和安全机制或允许访问23端口

    systemctl disable firewalld.service 
    systemctl stop firewalld.service 
    setenforce 0

    二丶升级openssh

  5. 备份ssh、pam.d 、openssh

    cp -ar /etc/ssh /mnt/
    cp -ar /etc/pam.d /mnt/
    cp -a /usr/bin/ssh /mnt/ssh.bak
    cp -a /usr/sbin/sshd /mnt/sshd.bak

  6. 上传并解压rpm包

    rz #选择rpm包
    unzip OpenSSH89p1_For_RHEL7_Build20220411.zip

  7. 安装openssh

    #查看现在openssh的版本
    [root@centos-7 ~]# rpm -qa |grep openssh
    openssh-7.4p1-16.el7.x86_64
    openssh-clients-7.4p1-16.el7.x86_64
    openssh-server-7.4p1-16.el7.x86_64

  8. 移动到解压出来的OpenSSH89p1 For RHEL7 Build20220411目录,并升级openssh

    #直升级现有的RPM包即可
    cd OpenSSH89p1\ For\ RHEL7\ Build20220411/
    rpm -Uvh openssh-server-8.9p1-1.el7.x86_64.rpm --force --nodeps
    rpm -Uvh openssh-8.9p1-1.el7.x86_64.rpm --force --nodeps
    rpm -Uvh openssh-clients-8.9p1-1.el7.x86_64.rpm --force --nodeps

  9. 查看是否升级成功

    [root@centos-7 OpenSSH89p1 For RHEL7 Build20220411]# rpm -qa |grep openssh
    openssh-8.9p1-1.el7.x86_64
    openssh-clients-8.9p1-1.el7.x86_64
    openssh-server-8.9p1-1.el7.x86_64

  10. 恢复sshd配置文件并重启ssh服务

    cp /mnt/ssh/sshd_config /etc/ssh
    systemctl restart sshd

  11. 测试是否能重新登录服务器,如登录成功,升级成功(步骤略)

  12. 关闭telnet和xinetd并取消开机自启

    systemctl disable xinetd
    systemctl disable telnet.socket 
    systemctl stop telnet.socket 
    systemctl stop xinetd.service 

  13. 删除telnet相关信息

    yum remove telnet*
    vim /etc/securetty
    #删除行尾
    pts/0
    pts/1
    pts/2
    pts/3

  14. 提取码:7g2p
    RPM包自提链接:https://pan.baidu.com/s/1dVn7gL02ox4tG9F-Ydsrkg 

你可能感兴趣的:(Linux系统管理,linux,运维,安全)