Make SSH port configurable

This commit is contained in:
Marek Miklewicz
2026-06-13 20:35:09 +02:00
parent 79f7952aac
commit d0ac04f38b
2 changed files with 9 additions and 5 deletions
+4 -5
View File
@@ -14,6 +14,7 @@ LOG_FILE=/var/log/dapostinstall.log
HTLINK="https://ht.zenadmin.pl" HTLINK="https://ht.zenadmin.pl"
DEFAULT_NS1=dns3.hitme.net.pl DEFAULT_NS1=dns3.hitme.net.pl
DEFAULT_NS2=dns4.hitme.net.pl DEFAULT_NS2=dns4.hitme.net.pl
SSH_PORT=10022
REDIS_VERSION=8 REDIS_VERSION=8
SETUP_TXT="$DADIR/conf/setup.txt" SETUP_TXT="$DADIR/conf/setup.txt"
PLUGIN_ARCHIVE_DIR="$DAPOSTINSTALL_DIR/plugins" 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" set_key_value "$DADIR/data/users/admin/reseller.conf" "ns2" "$DEFAULT_NS2"
systemctl restart directadmin systemctl restart directadmin
echo "Ustawienie domyslnego portu SSH na 10022" echo "Ustawienie domyslnego portu SSH na $SSH_PORT"
SSH_PORT=10022
sed -i '/Port 22/s/^#//g' /etc/ssh/sshd_config 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/Port 22/Port $SSH_PORT/g" /etc/ssh/sshd_config
sed -i "s/,22,/,22,10022,/g" /etc/csf/csf.conf sed -i "s/,22,/,22,$SSH_PORT,/g" /etc/csf/csf.conf
echo "Ustawienie dodatkowych zabezpieczen SSH" echo "Ustawienie dodatkowych zabezpieczen SSH"
+5
View File
@@ -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" '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_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" '^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" '^REDIS_VERSION=8$'
assert_file_contains "$ROOT_DIR/dapostinstall.sh" '^PLUGIN_ARCHIVE_DIR="\$DAPOSTINSTALL_DIR/plugins"$' 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"$' 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" '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" "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" '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" 'MIN_PASSWORD_LENGTH'
assert_file_not_contains "$ROOT_DIR/dapostinstall.sh" 'MAX_PASSWORD_LENGTH' assert_file_not_contains "$ROOT_DIR/dapostinstall.sh" 'MAX_PASSWORD_LENGTH'
assert_file_not_contains "$ROOT_DIR/dapostinstall.sh" 'ITERATION_LIMIT' assert_file_not_contains "$ROOT_DIR/dapostinstall.sh" 'ITERATION_LIMIT'