当前位置:首页 » 《休闲阅读》 » 正文

【Linux】环境下OpenSSH升级到 OpenSSH_9.6P1(图文教程)

24 人参与  2024年04月30日 09:45  分类 : 《休闲阅读》  评论

点击全文阅读


漏洞描述

OpenSSH(OpenBSD Secure Shell)是加拿大OpenBSD计划组的一套用于安全访问远程计算机的连接工具。该工具是SSH协议的开源实现,支持对所有的传输进行加密,可有效阻止窃听、连接劫持以及其他网络级的攻击。OpenSSH 9.6之前版本存在安全漏洞,该漏洞源于存在操作系统命令注入漏洞。

CVE编号

CVE-2023-51385

CNNVD编号

CNNVD-202312-1665

 解决方法:升级openssh版本至9.6

操作步骤

1.查看当前服务器的openssh版本

ssh -V

2.openssh下载地址

Index of /pub/OpenBSD/OpenSSH/portable/

3.对原来的openssh备份

(1)通过whereis ssh 找到openssh的文件

(2)备份ssh和sshd文件或目录

mv /etc/ssh /etc/ssh_old.bakmv /usr/bin/ssh /usr/bin/ssh_old.bakmv /usr/bin/ssh-keygen /usr/bin/ssh-keygen_old.bakmv /usr/sbin/sshd /usr/sbin/sshd_old.bakmv /etc/pam.d/sshd.pam /etc/pam.d/sshd.pam_old.bak

4.将openssh上传并解压

tar -zxvf openssh-9.6p1.tar.gz

5.卸载原有的openssh包

此命令会将找到的openssh相关的rpm包强制删除。

rpm -e --nodeps `rpm -qa | grep openssh`

6.编译安装openssh

(1)切换到解压后的openssh目录

cd openssh-9.6p1

(2)初始化openssh
./configure --prefix=/usr/local/openssh9p6 --sysconfdir=/etc/ssh --with-pam --with-zlib

大家可以通过命令查看初始化的参数信息 ./configure --help

若出现如下错误:那我们就重新编译安装高一点版本的openssl

error: OpenSSL >= 1.1.1 required (have "100020bf (OpenSSL 1.0.2k-fips 26 Jan 2017)")

重新下载一个openssl 我选择的是openssl1.1.1d版本 ,上传到服务器之后。

1)编译安装openssl

这里是相当于重新安装的openssl,单独给安装opensshs使用。

openssl下载地址:/source/old/index.html

tar -zxvf openssl-1.1.1d.tar.gz

cd openssl-1.1.1d
 
./config --prefix=/usr/local/openssl -d shared
 
make && make install  

 2)重新初始化openssh

切换到openssh,这次我们在初始化的时候加上刚刚安装好openssl的目录。

./configure --prefix=/usr/local/openssh9p6 --sysconfdir=/etc/ssh --with-pam --with-ssl-dir=/usr/local/openssl --with-zlib

如果安装单独的openssl之后,再执行初始化openssh命令报错 configure: error: OpenSSL headers,not found.那么openssl可能没安装成功,参考如下博客重新安装openssl并更新到系统服务中:【Linux】升级openssl版本-CSDN博客

(3)编译安装

make -j 4
make install

7.复制新的配置文件到原来目录

cp /usr/local/openssh9p6/sbin/sshd /usr/sbin/sshdcp /usr/local/openssh9p6/bin/ssh /usr/bin/sshcp /usr/local/openssh9p6/bin/ssh-keygen /usr/bin/ssh-keygen cp -p contrib/redhat/sshd.init /etc/init.d/sshd 

 8.添加权限

 chmod +x /etc/init.d/sshd 

 9.修改sshd_config文件(一定)

vim  /etc/ssh/sshd_config

PermitRootLogin yes 、PubkeyAuthentication yes、PasswordAuthentication yes 将配置文件中这几个改为yes.

说明:

PermitRootLogin yes:允许root用户通过SSH登录到系统
PubkeyAuthentication yes:启用公钥身份验证
PasswordAuthentication yes:启用密码身份验证

10.开启开机自启sshd

 systemctl enable sshd

11.重启sshd 

 systemctl restart sshd

 11.验证是否成功

sshd -V 




 


点击全文阅读


本文链接:http://zhangshiyu.com/post/102220.html

<< 上一篇 下一篇 >>

  • 评论(0)
  • 赞助本站

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

关于我们 | 我要投稿 | 免责申明

Copyright © 2020-2022 ZhangShiYu.com Rights Reserved.豫ICP备2022013469号-1