From d334ddc5016d34fabf79c73d59aeb98d2209c81f Mon Sep 17 00:00:00 2001 From: pablobae <33727260+pablobae@users.noreply.github.com> Date: Thu, 7 Feb 2019 16:49:43 +0100 Subject: [PATCH] Update v-add-firewall-chain Obtains the SSH port from the service configuration file (originally it was hardcoded). This allow the correct creation of ssh chain when this service has a custom port. --- bin/v-add-firewall-chain | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bin/v-add-firewall-chain b/bin/v-add-firewall-chain index c7b826fa..5026d264 100755 --- a/bin/v-add-firewall-chain +++ b/bin/v-add-firewall-chain @@ -47,7 +47,13 @@ is_system_enabled "$FIREWALL_SYSTEM" 'FIREWALL_SYSTEM' # Checking known chains case $chain in - SSH) port=22; protocol=TCP ;; + SSH) # Get ssh port by reading ssh config file. + sshport=$(grep '^Port ' /etc/ssh/sshd_config | head -1 | cut -d ' ' -f 2) + if [ -z "$sshport" ]; then + sshport=22 + fi + port=$sshport; + protocol=TCP ;; FTP) port=21; protocol=TCP ;; MAIL) port='25,465,587,2525,110,995,143,993'; protocol=TCP ;; DNS) port=53; protocol=UDP ;;