RedHat 7.0更新升级openSSH7.4p1

由于目前服务器上ssh版本较低,存在安全漏洞,需要升级到最新版本。

系统版本:RedHat 7.0

openSSH版本:6.4p1

openSSH版本:7.4p1

升级方式:源码安装

安装操作步骤如下:

1、更新ssl

#yum update openssl  

2、备份ssh目录

#cp -rf /etc/ssh /etc/ssh.bak  

注:安装telnet,以备ssh更新失败无法远程连接,如果可以现场操作可忽略

3、安装升级所需组件

#yum install -y gcc openssl-devel pam-devel rpm-build  

4、解压升级包,并安装

1
2
3
4
tar -zxvf openssh-7.4p1.tar.gz  
cd openssh-7.4p1 
./configure --prefix=/usr --sysconfdir=/etc/ssh --with-pam --with-zlib --with-md5-passwords  
make && make install

或者yum源安装

#yum -y install openssh openssh-clients openssh-server

需要安装客户端和服务端、启动服务端和设置下开机启动。

 

 

5、修改配置文件

vim /etc/ssh/sshd_config  

1)、修改PermitRootLogin

#PermitRootLogin yes
修改为
PermitRootLogin yes

2)、注释掉下面的新版本不支持的配置

#GSSAPIAuthentication yes

#GSSAPICleanupCredentials yes

 

编辑脚本ssh_chmod.sh并执行(这是执行查看状态发现权限不对进行相应的修改,可根据情况自行设置)

1
2
3
4
5
6
#!/bin/bash
cd /etc/ssh
chmod 600 ssh_host_rsa_key
chmod 640 ssh_host_ed25519_key
chown -R root:ssh_keys ssh_host_ed25519_key
chmod 600 ssh_host_ecdsa_key

 

6、重启SSH

#systemctl restart sshd

7、查看SSH状态

#systemctl status sshd

 

如需提前卸载旧版,可按照下述步骤操作

1、查看旧版openSSH

#rpm -qa | grep openssh 

2、卸载旧版openSSH

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

 

注:

1、在configure openssh时,如果有参数 –with-pam,会提示:“PAM is enabled. You may need to install a PAM control file for sshd, otherwise password authentication may fail. Example PAM control files can be found in the contrib/ subdirectory”提示文字,

就是如果启用PAM,需要有一个控制文件,按照提示的路径找到redhat/sshd.pam,并复制到/etc/pam.d/sshd,在/etc/ssh/sshd_config中打开UsePAM yes。发现连接服务器被拒绝,关掉就可以登录

https://blog.csdn.net/mayifan0/article/details/73293419

 

posted @   你好!2022  阅读(6465)  评论(0编辑  收藏  举报
编辑推荐:
· 用 C# 插值字符串处理器写一个 sscanf
· Java 中堆内存和栈内存上的数据分布和特点
· 开发中对象命名的一点思考
· .NET Core内存结构体系(Windows环境)底层原理浅谈
· C# 深度学习:对抗生成网络(GAN)训练头像生成模型
阅读排行:
· 为什么说在企业级应用开发中,后端往往是效率杀手?
· 本地部署DeepSeek后,没有好看的交互界面怎么行!
· 趁着过年的时候手搓了一个低代码框架
· 用 C# 插值字符串处理器写一个 sscanf
· 推荐一个DeepSeek 大模型的免费 API 项目!兼容OpenAI接口!
点击右上角即可分享
微信分享提示