From d0ac04f38b6d34a540bc0e96b7851273d713a237 Mon Sep 17 00:00:00 2001 From: Marek Miklewicz Date: Sat, 13 Jun 2026 20:35:09 +0200 Subject: [PATCH] Make SSH port configurable --- dapostinstall.sh | 9 ++++----- tests/quality_checks.sh | 5 +++++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/dapostinstall.sh b/dapostinstall.sh index d5b789f..d3288da 100755 --- a/dapostinstall.sh +++ b/dapostinstall.sh @@ -14,6 +14,7 @@ LOG_FILE=/var/log/dapostinstall.log HTLINK="https://ht.zenadmin.pl" DEFAULT_NS1=dns3.hitme.net.pl DEFAULT_NS2=dns4.hitme.net.pl +SSH_PORT=10022 REDIS_VERSION=8 SETUP_TXT="$DADIR/conf/setup.txt" PLUGIN_ARCHIVE_DIR="$DAPOSTINSTALL_DIR/plugins" @@ -228,12 +229,10 @@ set_key_value "$DADIR/data/users/admin/reseller.conf" "ns1" "$DEFAULT_NS1" set_key_value "$DADIR/data/users/admin/reseller.conf" "ns2" "$DEFAULT_NS2" systemctl restart directadmin -echo "Ustawienie domyslnego portu SSH na 10022" - -SSH_PORT=10022 +echo "Ustawienie domyslnego portu SSH na $SSH_PORT" sed -i '/Port 22/s/^#//g' /etc/ssh/sshd_config -sed -i "s/Port 22/Port 10022/g" /etc/ssh/sshd_config -sed -i "s/,22,/,22,10022,/g" /etc/csf/csf.conf +sed -i "s/Port 22/Port $SSH_PORT/g" /etc/ssh/sshd_config +sed -i "s/,22,/,22,$SSH_PORT,/g" /etc/csf/csf.conf echo "Ustawienie dodatkowych zabezpieczen SSH" diff --git a/tests/quality_checks.sh b/tests/quality_checks.sh index fbead8a..63f8a9a 100644 --- a/tests/quality_checks.sh +++ b/tests/quality_checks.sh @@ -100,6 +100,7 @@ assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'set_key_value "\$DADIR/conf/d assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'set_key_value "\$DADIR/conf/directadmin\.conf" "ns2"' assert_file_contains "$ROOT_DIR/dapostinstall.sh" '^DEFAULT_NS1=dns3\.hitme\.net\.pl$' assert_file_contains "$ROOT_DIR/dapostinstall.sh" '^DEFAULT_NS2=dns4\.hitme\.net\.pl$' +assert_file_contains "$ROOT_DIR/dapostinstall.sh" '^SSH_PORT=10022$' assert_file_contains "$ROOT_DIR/dapostinstall.sh" '^REDIS_VERSION=8$' assert_file_contains "$ROOT_DIR/dapostinstall.sh" '^PLUGIN_ARCHIVE_DIR="\$DAPOSTINSTALL_DIR/plugins"$' assert_file_contains "$ROOT_DIR/dapostinstall.sh" '^BRANDING_DIR="\$DAPOSTINSTALL_DIR/branding"$' @@ -128,6 +129,10 @@ assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'index-hitme\.html' assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'DA_ADMINPASS=\$\(get_key_value "\$SETUP_TXT" "adminpass"\)' assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'set_key_value "\$DADIR/conf/directadmin\.conf" "ns1" "\$DEFAULT_NS1"' assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'set_key_value "\$DADIR/conf/directadmin\.conf" "ns2" "\$DEFAULT_NS2"' +assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'sed -i "s/Port 22/Port \$SSH_PORT/g" /etc/ssh/sshd_config' +assert_file_contains "$ROOT_DIR/dapostinstall.sh" 'sed -i "s/,22,/,22,\$SSH_PORT,/g" /etc/csf/csf\.conf' +assert_file_not_contains "$ROOT_DIR/dapostinstall.sh" 'Port 10022' +assert_file_not_contains "$ROOT_DIR/dapostinstall.sh" ',22,10022,' assert_file_not_contains "$ROOT_DIR/dapostinstall.sh" 'MIN_PASSWORD_LENGTH' assert_file_not_contains "$ROOT_DIR/dapostinstall.sh" 'MAX_PASSWORD_LENGTH' assert_file_not_contains "$ROOT_DIR/dapostinstall.sh" 'ITERATION_LIMIT'