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

相关推荐
haluhalu.2 分钟前
从 Linux 线程控制到 pthread 库
java·linux·服务器
水境传感 张园园3 分钟前
自来水厂水质监测站:用数据守护饮水安全
运维·服务器·网络
2023自学中3 分钟前
Cortex-M系列,Cortex-A系列,汇编启动文件的区别
linux·嵌入式硬件
APIshop8 分钟前
实战代码解析:item_get——获取某鱼商品详情接口
java·linux·数据库
楼田莉子9 分钟前
Linux系统小项目——“主从设计模式”进程池
linux·服务器·开发语言·c++·vscode·学习
七夜zippoe9 分钟前
2026年1月远程工具横评:UU远程以全能六边形战士之姿,重塑行业性能标杆
运维·效率·远程·uu·安全锁
gs8014015 分钟前
【Xinference实战】解决部署Qwen3/vLLM时遇到的 max_model_len 超限与 Engine Crash 报错
运维·服务器
知数SEO25 分钟前
Centos如何安装高版本Python
linux·python·centos
CCTI_Curran28 分钟前
迷你标签打印机做TELEC认证注意事项
运维·服务器·wifi·蓝牙·telec认证·日本认证·无线产品
Source.Liu36 分钟前
【IT工具】Ubuntu 环境下使用 Flask
linux·ubuntu·flask