centos7下升级openssh9.4p1及openssl1.1.1v版本

背景:客户服务器扫描出一些漏洞,发现和版本有关,漏洞最高的版本是9.3p2,所以我们安装一个openssh9.4p1版本及openssl1.1.1v版本

虽然我们进行了镜像备份,为了安全先安装telnet以防止升级失败无法通过ssh连接服务器

一、安装telnet

1、安装配置telnet,一般Linux系统自带telnet客户端,只需安装服务端即可,另外telnet运行需要依靠xinetd组件

yum install telnet-server.x86_64 xinetd.x86_64

2、运行telnet服务

systemctl enable telnet.socket

systemctl start telnet.socket

systemctl start xinetd

systemctl status telnet.socket

3、移除文件

linux默认不允许root账户telnet远程登录,需要移除配置文件,保证root账户能够远程登录

mv /etc/securetty /etc/securetty.bak

firewall-cmd --zone=public --add-port=23/tcp --permanent

firewall-cmd --reload

4、使用xshell工具telnet协议连接服务器

二、安装openssl及openssh

下载安装包

cd /home/openssh_package

wget --no-check-certificate https://www.openssl.org/source/openssl-1.1.1v.tar.gz

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

2.1 升级openssl

1、备份原来的openssl

mv /usr/bin/openssl /usr/bin/openssl_bak

mv /usr/include/openssl /usr/include/openssl_bak

2、解压源码包

tar -zxvf openssl-1.1.1v.tar.gz

3、进行编译安装

安装依赖包

yum -y install zlib* pam-* gcc make

cd openssl-1.1.1v/

./config --prefix=/usr/local/openssl --shared

make

make install

4、配置软连接,如果提示已存在,参数换位-b,并使用openssl version查看版本

ln -sf /usr/local/openssl/bin/openssl /usr/bin/openssl

ln -s /usr/local/openssl/lib/libssl.so.1.1 /usr/lib64/libssl.so.1.1

ln -s /usr/local/openssl/lib/libcrypto.so.1.1 /usr/lib64/libcrypto.so.1.1

2.2 升级openssh

1、更改ssh目录名,在升级时如果ssh目录存在,配置文件不会被覆盖

mv /etc/ssh /etc/ssh_bak

2、解压源码包

tar -zxvf openssh-9.4p1.tar.gz

安装pam

yum -y install pam-devel

安装依赖包

yum -y install zlib* pam-* gcc make

3、编译安装

./configure --prefix=/usr/ --sysconfdir=/etc/ssh --with-openssl-includes=/usr/local/openssl/include --with-ssl-dir=/usr/local/openssl --with-zlib --with-md5-passwords --with-pam

make -j4

make install

4、复制配置文件

cp -a contrib/redhat/sshd.init /etc/init.d/sshd

chmod u+x /etc/init.d/sshd

5、配置/etc/ssh/sshd_config文件,允许root账户远程登录

vim /etc/ssh/sshd_config

PasswordAuthentication yes //取消该行注释

PermitRootLogin yes //添加该行,允许root账户远程登录

6、添加ssh开机自启动

chkconfig --add sshd

chkconfig sshd on

7、更改root密码

passwd root

输入新的密码

重启sshd服务

systemctl restart sshd

8、使用新密码重新连接服务器

9、查看ssh的版本

版本已更新

如果开始没有mv /etc/ssh操作可能存在的问题:

1、Permissions 0640 for '/etc/ssh/ssh_host_ed25519_key' are too open

ssh权限太大

解决办法:

权限变成600

chmod 0600 /etc/ssh/ssh_host_rsa_key

chmod 0600 /etc/ssh/ssh_host_ecdsa_key

chmod 0600 /etc/ssh/ssh_host_ed25519_key

2、/etc/ssh/sshd_config line 79: Unsupported option GSSAPIAuthentication

/etc/ssh/sshd_config line 80: Unsupported option GSSAPICleanupCredentials

解决办法

注释掉/etc/ssh/sshd_config文件的79和80行

相关推荐
人生苦短,菜的抠脚29 分钟前
Linux 内核IIO sensor驱动
linux·驱动开发
jz_ddk42 分钟前
[LVGL] 从0开始,学LVGL:进阶应用与项目实战(上)
linux·信息可视化·嵌入式·gui·lvgl·界面设计
ITKEY_1 小时前
ssh中neovim无法复制文本 clipboard
运维·ssh
Bruce_Liuxiaowei1 小时前
Windows系统错误6118全面解决方案:修复此工作组的服务器列表当前无法使用
运维·服务器·windows·网络安全
望获linux1 小时前
【实时Linux实战系列】Linux 内核的实时组调度(Real-Time Group Scheduling)
java·linux·服务器·前端·数据库·人工智能·深度学习
云宏信息1 小时前
【深度解析】VMware替代的关键一环:云宏ROW快照如何实现高频业务下的“无感”数据保护?
服务器·网络·数据库·架构·云计算·快照
坐吃山猪1 小时前
zk02-知识演进
运维·zookeeper·debian
MC丶科1 小时前
【SpringBoot常见报错与解决方案】端口被占用?Spring Boot 修改端口号的 3 种方法,第 3 种 90% 的人不知道!
java·linux·spring boot
江公望2 小时前
ubuntu kylin(优麒麟)和标准ubuntu的区别浅谈
linux·服务器·ubuntu·kylin
Lynnxiaowen2 小时前
今天我们开始学习python语句和模块
linux·运维·开发语言·python·学习