包含centos升级openssh需要的3个 openssh 9.2p1rpm包,自解压升级。
脚本内容,修复了升级后无法ssh,无法使用rsa证书登录的问题:
#!/bin/bash
update_ssh()
{
cp /etc/ssh/sshd_config /etc/ssh/sshd_config.old
rpm -Uvh openssh*el7*.rpm --nodeps --force
cat /etc/ssh/sshd_config.old > /etc/ssh/sshd_config
cat <<EOF> /etc/pam.d/sshd
#%PAM-1.0
auth required pam_sepermit.so
auth include password-auth
account required pam_nologin.so
account include password-auth
password include password-auth
## pam_selinux.so close should be the first session rule
session required pam_selinux.so close
session required pam_loginuid.so
## pam_selinux.so open should only be followed by sessions to be executed in the user context
session required pam_selinux.so open env_params
session optional pam_keyinit.so force revoke
session include password-auth
EOF
###
sed -i 's/#PermitRootLogin/PermitRootLogin/g' /etc/ssh/sshd_config
cat <<EOF>> /etc/ssh/sshd_config
PubkeyAuthentication yes
HostkeyAlgorithms +ssh-rsa
PubkeyAcceptedAlgorithms +ssh-rsa
EOF
chmod 600 /etc/ssh/*
###
systemctl restart sshd
###
ssh -V
}
update_ssh
文件见附件, 拷贝到centos主机赋权执行。
chamod a+x opensshUp9.sh && ./opensshUp9.sh