Skip to content

Commit b974b79

Browse files
committed
Add changed port detection for ssh ports.
1 parent af550ba commit b974b79

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

bin/v-add-firewall-chain

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,13 @@ is_system_enabled "$FIREWALL_SYSTEM" 'FIREWALL_SYSTEM'
4747

4848
# Checking known chains
4949
case $chain in
50-
SSH) port=22; protocol=TCP ;;
50+
SSH) # Get ssh port by reading ssh config file.
51+
sshport=$(grep '^Port ' /etc/ssh/sshd_config | head -1 | cut -d ' ' -f 2)
52+
if [ -z "$sshport" ]; then
53+
sshport=22
54+
fi
55+
port=$sshport;
56+
protocol=TCP ;;
5157
FTP) port=21; protocol=TCP ;;
5258
MAIL) port='25,465,587,110,995,143,993'; protocol=TCP ;;
5359
DNS) port=53; protocol=UDP ;;

0 commit comments

Comments
 (0)