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

相关推荐
航Hang*2 小时前
第1章:初识Linux系统——第13节:总复习②
linux·笔记·学习·centos
Amy_au2 小时前
Linux week 01
linux·运维·服务器
dblens 数据库管理和开发工具2 小时前
Git 指令大全(全干货版)
运维·git·ubuntu
KingRumn2 小时前
DBUS源码剖析之DBusMessage数据结构
linux·服务器·数据结构
bst@微胖子2 小时前
Linux下排查网络偶现超时问题
linux·网络·dubbo
阿豪只会阿巴3 小时前
【多喝热水系列】从零开始的ROS2之旅——Day3
linux·笔记·ubuntu·ros2
OpenMiniServer3 小时前
JsonKV协议技术文档
linux·服务器·网络
小鹏linux3 小时前
【linux】进程与服务管理命令 - chkconfig
linux·运维·服务器
DeeplyMind4 小时前
linux VMA创建场景详解
linux·mmap·vma