银河麒麟修复openssh升级脚本

#!/bin/bash

备份相关配置文件

cp /etc/pam.d/sshd /etc/pam.d/sshd.before

cp /etc/ssh/sshd_config /etc/ssh/sshd_config.before

安装OpenSSH的rpm包

rpm -Uvh *.rpm

进入ssh配置目录并设置密钥权限

cd /etc/ssh/

chmod 400 ssh_host_ecdsa_key ssh_host_ed25519_key ssh_host_rsa_key

修改sshd_config配置项

echo "PermitRootLogin yes" >> /etc/ssh/sshd_config

sed -i 's/#UsePAM no/UsePAM yes/g' /etc/pam.d/sshd

/bin/cp /etc/pam.d/sshd.before /etc/pam.d/sshd

清空相关算法配置项

sed -i '/KexAlgorithms/d' /etc/ssh/sshd_config

sed -i '/GSSAPIKexAlgorithms/d' /etc/ssh/sshd_config

sed -i '/HostKeyAlgorithms/d' /etc/ssh/sshd_config

写入新的算法配置

echo "KexAlgorithms curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,curve25519-sha256@libssh.org" >> /etc/ssh/sshd_config

echo "HostKeyAlgorithms +ssh-rsa" >> /etc/ssh/sshd_config

重启sshd服务

systemctl restart sshd

相关推荐
珠海西格电力科技12 分钟前
微电网能量平衡理论的实现条件在不同场景下有哪些差异?
运维·服务器·网络·人工智能·云计算·智慧城市
A星空12325 分钟前
一、Linux嵌入式的I2C驱动开发
linux·c++·驱动开发·i2c
释怀不想释怀30 分钟前
Linux环境变量
linux·运维·服务器
zzzsde36 分钟前
【Linux】进程(4):进程优先级&&调度队列
linux·运维·服务器
凡人叶枫1 小时前
C++中智能指针详解(Linux实战版)| 彻底解决内存泄漏,新手也能吃透
java·linux·c语言·开发语言·c++·嵌入式开发
yuanmenghao1 小时前
Linux 性能实战 | 第 7 篇 CPU 核心负载与调度器概念
linux·网络·性能优化·unix
qq_297574671 小时前
Linux 服务器 Java 开发环境搭建保姆级教程
java·linux·服务器
70asunflower2 小时前
Emulation,Simulation,Virtualization,Imitation 的区别?
linux·docker
聆风吟º2 小时前
CANN开源项目实战指南:使用oam-tools构建自动化故障诊断与运维可观测性体系
运维·开源·自动化·cann
NPE~2 小时前
自动化工具Drissonpage 保姆级教程(含xpath语法)
运维·后端·爬虫·自动化·网络爬虫·xpath·浏览器自动化