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

相关推荐
池央1 小时前
CANN 算子生态的深度演进:稀疏计算支持与 PyPTO 范式的抽象层级
运维·人工智能·信号处理
郝学胜-神的一滴1 小时前
深入解析C/S模型下的TCP通信流程:从握手到挥手的技术之旅
linux·服务器·c语言·网络·网络协议·tcp/ip
OJAC1111 小时前
当所有人都在说“运维稳了”,近屿智能看到了另一种可能
运维
释怀不想释怀1 小时前
Linux网络基础(ip,域名)
linux·网络·tcp/ip
初願致夕霞1 小时前
Linux_进程
linux·c++
人鱼传说1 小时前
docker desktop是一个好东西
运维·docker·容器
开开心心就好1 小时前
AI人声伴奏分离工具,离线提取伴奏K歌用
java·linux·开发语言·网络·人工智能·电脑·blender
lucky-billy2 小时前
Ubuntu 下一键部署 ROS2
linux·ubuntu·ros2
Thera7772 小时前
【Linux C++】彻底解决僵尸进程:waitpid(WNOHANG) 与 SA_NOCLDWAIT
linux·服务器·c++
阿梦Anmory2 小时前
Ubuntu配置代理最详细教程
linux·运维·ubuntu