赞
踩
话不多说,直接进入正题。由于升级ssh版本存在升级失败导致无法连接服务器,所以需要先开启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以及需要的依赖
- mkdir telnet
- cd telnet
- 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")
- cd ..
- tar zcvf telnet.tar.gz telnet
2.将telnet和依赖上传至目标服务器
scp telnet.tar.gz root@x.x.x.x:/opt
3.解压telnet和依赖上
- cd /opt
- tar -zvxf telnet.tar.gz
4.安装telnet服务
- cd telnet
- dpkg -i *
5.验证安装是否正确,已经是否能够登录和在线环境测试步骤一致
- sudo netstat -a | grep telnet
- telnet x.x.x.x //等登录即可
1.查看当前版本
sshd -V
2.当前ssh状态
systemctl status sshd
3.安装当前源最新版ssh
- apt update
- apt install openssh-server
4.验证
- ssh -V
- OpenSSH_8.9p1 Ubuntu-3ubuntu0.10, OpenSSL 3.0.2 15 Mar 2022 //此结果升级完成
1.在能联网的环境下载ssh以及需要的依赖
- mkdir ssh
- cd ssh
- 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")
- rm -rf ssh* //删除当前版本的ssh
- cd ..
- tar zcvf ssh.tar.gz ssh
下载编译所需环境
- mkdir gcc
- cd gcc
- 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")
- 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")
- 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")
- 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")
-
- cd ..
- 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.解压文件
- tar -zvxf ssh.tar.gz
- tar -zvxf openssh-9.8p1.tar.gz
- tar -zvxf gcc.tar.gz
5.首先安装依赖后安装ssh服务
- cd ssh
- dpkg -i *
- cd ..
- cd gcc
- dpkg -i *
6.安装ssh
- cd openssh-9.8p1
- ./configure
- make
- make install
- systemctl restart sshd
7.验证
- ssh -V
- OpenSSH_8.9p1 Ubuntu-3ubuntu0.10, OpenSSL 3.0.2 15 Mar 2022 //此结果升级完成
8.升级完毕,关闭telnet服务
- netstat -a |grep telnet
- update-rc.d -f telnetd remove
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。