add custom file in sshd_config.d to override but not modify original config

main
AhFei 2023-11-21 00:30:21 +08:00
parent 703c81a39c
commit 37ee37ef9a
1 changed files with 7 additions and 3 deletions

View File

@ -37,9 +37,13 @@ usermod -aG docker ${nml_user_name}
echo "${nml_user_name}:${password}" | chpasswd
# 修改ssh端口和禁止root登陆
cp ${SSHCONF} ${SSHCONF}.bak
sed -i "s/Port 22/Port ${new_port}/g" "${SSHCONF}"
sed -i 's/PermitRootLogin yes/PermitRootLogin no/g' "${SSHCONF}"
# cp ${SSHCONF} ${SSHCONF}.bak
# sed -i "s/Port 22/Port ${new_port}/g" "${SSHCONF}"
# sed -i 's/PermitRootLogin yes/PermitRootLogin no/g' "${SSHCONF}"
cat > /etc/ssh/sshd_config.d/custom_sshd.conf << EOF
Port ${new_port}
PermitRootLogin yes
EOF
timedatectl set-timezone Asia/Shanghai
echo `date`