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

相关推荐
Sheffield7 小时前
Docker的跨主机服务与其对应的优缺点
linux·网络协议·docker
Sheffield15 小时前
Alpine是什么,为什么是Docker首选?
linux·docker·容器
舒一笑1 天前
程序员效率神器:一文掌握 tmux(服务器开发必备工具)
运维·后端·程序员
Johny_Zhao1 天前
centos7安装部署openclaw
linux·人工智能·信息安全·云计算·yum源·系统运维·openclaw
haibindev1 天前
在 Windows+WSL2 上部署 OpenClaw AI员工的实践与踩坑
linux·wsl2·openclaw
NineData1 天前
数据库管理工具NineData,一年进化成为数万+开发者的首选数据库工具?
运维·数据结构·数据库
梦想很大很大2 天前
拒绝“盲猜式”调优:在 Go Gin 项目中落地 OpenTelemetry 链路追踪
运维·后端·go
Sinclair2 天前
内网服务器离线安装 Nginx+PHP+MySQL 的方法
运维
叶落阁主2 天前
Tailscale 完全指南:从入门到私有 DERP 部署
运维·安全·远程工作