]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
TEST-74-AUX-UTILS: use sshd_config.d
authorval4oss <val4oss@pm.me>
Wed, 1 Oct 2025 15:32:53 +0000 (17:32 +0200)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 4 Oct 2025 21:00:31 +0000 (23:00 +0200)
* From the TEST-74-AUX-UTILS.ssh.sh writing directly into
  /etc/ssh/sshd_config can hide config from distro using /usr/etc.
* Using directory configuration /etc/ssh/sshd_config.d/* suits for all
  cases.

Signed-off-by: val4oss <val4oss@pm.me>
test/units/TEST-74-AUX-UTILS.ssh.sh

index 890763c9dc9c92b8c050ce896220533681bccf4d..d18e679075cbc1a4c28977ef06c93055a49dcc36 100755 (executable)
@@ -43,8 +43,17 @@ usermod -U root
 
 mkdir -p /etc/ssh
 test -f /etc/ssh/ssh_host_rsa_key || ssh-keygen -t rsa -C '' -N '' -f /etc/ssh/ssh_host_rsa_key
-echo "PermitRootLogin yes" >> /etc/ssh/sshd_config
-echo "LogLevel DEBUG3" >> /etc/ssh/sshd_config
+
+SSHD_CONF_P="/etc/ssh/sshd_config.d/test.conf"
+mkdir -p "$(basename ${SSHD_CONF_P})"
+{
+    echo "PermitRootLogin yes"
+    echo "LogLevel DEBUG3"
+} >"${SSHD_CONF_P}"
+rm_sshd_conf() {
+    rm -f "${SSHD_CONF_P}"
+}
+trap rm_sshd_conf EXIT
 
 test -f /etc/ssh/ssh_config || {
     echo 'Include /etc/ssh/ssh_config.d/*.conf'