mirror of
https://github.com/deadcxap/init_scripts.git
synced 2026-07-02 05:43:40 +03:00
Изменена логика добавления SSH drop-in
This commit is contained in:
@@ -136,7 +136,7 @@ configure_ssh() {
|
|||||||
base=\$(basename \"\$f\")
|
base=\$(basename \"\$f\")
|
||||||
case \"\$base\" in
|
case \"\$base\" in
|
||||||
[0-9][0-9]-*.conf)
|
[0-9][0-9]-*.conf)
|
||||||
[[ \$base == 99-* ]] && mv \"\$f\" \"\${f%.conf}.disabled\"
|
[[ \$base == 00-* ]] && mv \"\$f\" \"\${f%.conf}.disabled\"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
mv \"\$f\" \"\${f%.conf}.disabled\"
|
mv \"\$f\" \"\${f%.conf}.disabled\"
|
||||||
@@ -144,14 +144,14 @@ configure_ssh() {
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
shopt -u nullglob
|
shopt -u nullglob
|
||||||
max=\$(find \"\$dir\" -maxdepth 1 -type f -name '[0-9][0-9]-*.conf' | sed -n 's#.*/\\([0-9][0-9]\\)-.*#\\1#p' | sort -n | tail -1)
|
min=\$(find "\$dir" -maxdepth 1 -type f -name '[0-9][0-9]-*.conf' | sed -n 's#.*/\([0-9][0-9]\)-.*#\1#p' | sort -n | head -1)
|
||||||
if [ -z \"\$max\" ]; then
|
if [ -z "\$min" ]; then
|
||||||
next=10
|
next=0
|
||||||
else
|
else
|
||||||
next=\$((10#\$max + 10))
|
next=\$((10#\$min - 10))
|
||||||
[ \"\$next\" -gt 99 ] && next=99
|
[ "\$next" -lt 0 ] && next=0
|
||||||
fi
|
fi
|
||||||
newfile=\$(printf '%s/%02d-hardening.conf' \"\$dir\" \"\$next\")
|
newfile=\$(printf '%s/%02d-hardening.conf' "\$dir" "\$next")
|
||||||
printf \"%s\n\" 'PasswordAuthentication no' 'PermitRootLogin no' 'KbdInteractiveAuthentication no' > \"\$newfile\"
|
printf \"%s\n\" 'PasswordAuthentication no' 'PermitRootLogin no' 'KbdInteractiveAuthentication no' > \"\$newfile\"
|
||||||
chown root:root \"\$newfile\"
|
chown root:root \"\$newfile\"
|
||||||
chmod 0644 \"\$newfile\"
|
chmod 0644 \"\$newfile\"
|
||||||
|
|||||||
Reference in New Issue
Block a user