银河麒麟修复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

相关推荐
云栖梦泽15 分钟前
Linux内核与驱动:14.SPI子系统
linux·运维·服务器·c++
福大大架构师每日一题19 分钟前
openclaw v2026.4.24 发布:Google Meet 深度集成、DeepSeek V4 上线、浏览器自动化与插件架构全面升级
运维·架构·自动化·openclaw
yipiantian42 分钟前
在Claude项目中实现跨目录访问Skills
linux·运维·服务器
Agent产品评测局1 小时前
生产排期与MES/ERP系统打通,实操方法详解 —— 2026企业级智能体自动化选型与实战指南
java·运维·人工智能·ai·chatgpt·自动化
cen__y1 小时前
Linux07(信号01)
linux·运维·服务器·c语言·开发语言
MT5开发1 小时前
Linux安装MariaDB
linux·运维·mariadb
Lentou2 小时前
日志轮询策略
linux·服务器·网络
Yoyo25年秋招冲冲冲2 小时前
【亲测可用】ubuntu系统下安装Openclaw+配置飞书
linux·ubuntu·ai·飞书·openclaw
你好,帅哥2 小时前
openssl ,msys2 ,交叉编译
linux·运维·服务器
计算机安禾2 小时前
【Linux从入门到精通】第36篇:DNS服务探秘——自己搭建一个内网DNS
linux·运维·servlet