Update ssh.sh

This commit is contained in:
spiritlhl 2023-08-02 12:18:13 +08:00 committed by GitHub
parent 433dfc1104
commit ef8438930f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -156,14 +156,14 @@ if [ -f "/etc/selinux/config" ]; then
fi fi
setenforce 0; setenforce 0;
if [ -f /etc/ssh/sshd_config ]; then if [ -f /etc/ssh/sshd_config ]; then
sed -i "s/^#\?Port.*/Port $sshport/g" /etc/ssh/sshd_config sed -i 's/^#\?Port.*/Port $sshport/g' /etc/ssh/sshd_config
sed -i "s/^#\?PermitRootLogin.*/PermitRootLogin yes/g" /etc/ssh/sshd_config sed -i 's/^#\?PermitRootLogin.*/PermitRootLogin yes/g' /etc/ssh/sshd_config
sed -i "s/^#\?PasswordAuthentication.*/PasswordAuthentication yes/g" /etc/ssh/sshd_config sed -i 's/^#\?PasswordAuthentication.*/PasswordAuthentication yes/g' /etc/ssh/sshd_config
sed -i 's/#ListenAddress 0.0.0.0/ListenAddress 0.0.0.0/' /etc/ssh/sshd_config sed -i 's/#ListenAddress 0.0.0.0/ListenAddress 0.0.0.0/' /etc/ssh/sshd_config
sed -i 's/#ListenAddress ::/ListenAddress ::/' /etc/ssh/sshd_config sed -i 's/#ListenAddress ::/ListenAddress ::/' /etc/ssh/sshd_config
sed -i 's/#AddressFamily any/AddressFamily any/' /etc/ssh/sshd_config sed -i 's/#AddressFamily any/AddressFamily any/' /etc/ssh/sshd_config
sed -i '/^#UsePAM\|UsePAM/c #UsePAM no' /etc/ssh/sshd_config sed -i '/^#UsePAM\|UsePAM/c #UsePAM no' /etc/ssh/sshd_config
sed -i "s/^#\?PubkeyAuthentication.*/PubkeyAuthentication no/g" /etc/ssh/sshd_config sed -i 's/^#\?PubkeyAuthentication.*/PubkeyAuthentication no/g' /etc/ssh/sshd_config
sed -i '/^AuthorizedKeysFile/s/^/#/' /etc/ssh/sshd_config sed -i '/^AuthorizedKeysFile/s/^/#/' /etc/ssh/sshd_config
fi fi
if [ -f /etc/ssh/sshd_config.d/50-cloud-init.conf ]; then if [ -f /etc/ssh/sshd_config.d/50-cloud-init.conf ]; then