当前位置:   article > 正文

ubuntu22.04升级ssh版本至9.8p1_ubuntu22.04离线升级openssh到9.8

ubuntu22.04离线升级openssh到9.8

话不多说,直接进入正题。由于升级ssh版本存在升级失败导致无法连接服务器,所以需要先开启telnet服务器

一.安装telnet服务

在线环境

1.安装telnet服务

sudo apt-get install telnetd -y

2.确认服务器已经启动

sudo netstat -a | grep telnet

3.验证telnet服务可用(找一台登录此服务器的pc)

telnet x.x.x.x  //等登录即可

离线环境

1.在能联网的环境下载telnet以及需要的依赖

  1. mkdir telnet
  2. cd telnet
  3. apt-get download $(apt-cache depends --recurse --no-recommends --no-suggests --no-conflicts --no-breaks --no-replaces --no-enhances --no-pre-depends telnetd | grep -v i386 | grep "^\w")
  4. cd ..
  5. tar zcvf telnet.tar.gz telnet

2.将telnet和依赖上传至目标服务器

scp  telnet.tar.gz root@x.x.x.x:/opt

3.解压telnet和依赖上

  1. cd /opt
  2. tar -zvxf telnet.tar.gz

4.安装telnet服务

  1. cd telnet
  2. dpkg -i *

5.验证安装是否正确,已经是否能够登录和在线环境测试步骤一致

  1. sudo netstat -a | grep telnet
  2. telnet x.x.x.x //等登录即可

二.升级ssh版本

在线升级

1.查看当前版本

sshd -V

2.当前ssh状态

 systemctl status sshd

3.安装当前源最新版ssh

  1. apt update
  2. apt install openssh-server

4.验证

  1. ssh -V
  2. OpenSSH_8.9p1 Ubuntu-3ubuntu0.10, OpenSSL 3.0.2 15 Mar 2022 //此结果升级完成

离线升级

1.在能联网的环境下载ssh以及需要的依赖

  1. mkdir ssh
  2. cd ssh
  3. apt-get download $(apt-cache depends --recurse --no-recommends --no-suggests --no-conflicts --no-breaks --no-replaces --no-enhances --no-pre-depends ssh | grep -v i386 | grep "^\w")
  4. rm -rf ssh* //删除当前版本的ssh
  5. cd ..
  6. tar zcvf ssh.tar.gz ssh

下载编译所需环境

  1. mkdir gcc
  2. cd gcc
  3. apt-get download $(apt-cache depends --recurse --no-recommends --no-suggests --no-conflicts --no-breaks --no-replaces --no-enhances --no-pre-depends build-essential | grep -v i386 | grep "^\w")
  4. apt-get download $(apt-cache depends --recurse --no-recommends --no-suggests --no-conflicts --no-breaks --no-replaces --no-enhances --no-pre-depends make | grep -v i386 | grep "^\w")
  5. apt-get download $(apt-cache depends --recurse --no-recommends --no-suggests --no-conflicts --no-breaks --no-replaces --no-enhances --no-pre-depends zlib1g-dev| grep -v i386 | grep "^\w")
  6. apt-get download $(apt-cache depends --recurse --no-recommends --no-suggests --no-conflicts --no-breaks --no-replaces --no-enhances --no-pre-depends libssl-dev| grep -v i386 | grep "^\w")
  7. cd ..
  8. tar zxcf gcc.tar.gz gcc

2.下载要升级版本的ssh(由于ssh-rce漏洞影响本文升级以9.8p为例)

https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/   //下载需要升级的版本

9.8p版本

wget  https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-9.8p1.tar.gz

3. 将ssh依赖和ssh安装包上传至目标服务器

scp ssh.tar.gz  openssh-9.8p1.tar.gz gcc.tar.gz root@x.x.x.x:/opt

4.解压文件

  1. tar -zvxf ssh.tar.gz
  2. tar -zvxf openssh-9.8p1.tar.gz
  3. tar -zvxf gcc.tar.gz

5.首先安装依赖后安装ssh服务

  1. cd ssh
  2. dpkg -i *
  3. cd ..
  4. cd gcc
  5. dpkg -i *

6.安装ssh

  1. cd openssh-9.8p1
  2. ./configure
  3. make
  4. make install
  5. systemctl restart sshd

7.验证

  1. ssh -V
  2. OpenSSH_8.9p1 Ubuntu-3ubuntu0.10, OpenSSL 3.0.2 15 Mar 2022 //此结果升级完成

8.升级完毕,关闭telnet服务

  1. netstat -a |grep telnet
  2. update-rc.d -f telnetd remove

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/喵喵爱编程/article/detail/845804
推荐阅读
相关标签
  

闽ICP备14008679号