From 73a2fba22441b7049492c00c06ac794bb58852c8 Mon Sep 17 00:00:00 2001 From: LamGC Date: Sat, 28 Jan 2023 19:58:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20allow-root-passwd=20?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- conf-sshd.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/conf-sshd.sh b/conf-sshd.sh index 5eeb9d6..a48c87c 100644 --- a/conf-sshd.sh +++ b/conf-sshd.sh @@ -141,10 +141,12 @@ if [ $(has_param "-p" "--allow-root-passwd") == "true" ]; then allow_root_passwd=$(get_param_value "-p" "--allow-root-passwd" | tr '[:upper:]' '[:lower:]') if [ "$allow_root_passwd" == "yes" ]; then # 设置允许 root 使用密码登录 - sed -i 's/PermitRootLogin.*/PermitRootLogin yes/g' /etc/ssh/sshd_config + sed -i 's/^#?PermitRootLogin.*/PermitRootLogin yes/g' /etc/ssh/sshd_config + echo "Root user is allowed to log in with password." elif [ "$allow_root_passwd" == "no" ]; then # 设置禁止 root 使用密码登录 - sed -i 's/PermitRootLogin.*/PermitRootLogin no/g' /etc/ssh/sshd_config + sed -i 's/^#?PermitRootLogin.*/PermitRootLogin prohibit-password/g' /etc/ssh/sshd_config + echo "Root user is prohibited from logging in with password." else echo "Please specify whether to allow root to log in with a password." exit 1