银河麒麟修复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 分钟前
【极简监控】不骗篇幅!7个零运维成本的排障“微操”,让线上问题彻底左移
java·运维·监控
开开心心就好15 分钟前
进程启动瞬间暂停工具,适合调试多开
linux·运维·安全·pdf·智能音箱·智能手表·1024程序员节
祭曦念24 分钟前
MySQL基础运维:日志基础之慢查询日志与错误日志 | 作用、配置与查看方法全实战
运维·mysql·adb
win x33 分钟前
一篇搞懂Git基础操作
linux·git
吴声子夜歌41 分钟前
TypeScript——内置工具类型、类型查询、类型断言和类型细化
linux·ubuntu·typescript
刚入门的大一新生44 分钟前
Linux-Linux基础指令2
linux·运维·服务器
一招定胜负1 小时前
在 Windows 11 家庭版安装 Docker Desktop解决虚拟化问题
运维·docker·容器
hweiyu001 小时前
Linux命令:screen
linux·运维·服务器
i建模1 小时前
Docker API 版本冲突问题
运维·docker·容器
Meya11271 小时前
告别机房 U 位管理内耗!这套系统让运维效率直接拉满 ✨
大数据·运维·人工智能