File tree Expand file tree Collapse file tree 2 files changed +7
-6
lines changed
Expand file tree Collapse file tree 2 files changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -56,8 +56,8 @@ heal_iptables_links
5656
5757# Checking known chains
5858case $chain in
59- SSH) # Get ssh port by reading ssh config file .
60- sshport= $( grep ' ^Port ' /etc/ssh/sshd_config | head -1 | cut -d ' ' -f 2 )
59+ SSH) # Get ssh port (or ports) using v-list-sys-sshd-port .
60+ sshport= " $( $BIN /v-list-sys-sshd-port plain | sed ' :a;N;$!ba;s/\n/,/g ' ) "
6161 if [ -z " $sshport " ]; then
6262 sshport=22
6363 fi
Original file line number Diff line number Diff line change @@ -60,10 +60,11 @@ if [ $? -ne 0 ]; then
6060 conntrack_ftp=' no'
6161fi
6262
63- # Checking custom OpenSSH port
64- sshport=$( grep ' ^Port ' /etc/ssh/sshd_config | head -1 | cut -d ' ' -f 2)
65- if [[ " $sshport " =~ ^[0-9]+$ ]] && [ " $sshport " -ne " 22" ]; then
66- sed -i " s/PORT='22'/PORT=\'$sshport \'/" $rules
63+ # Checking custom OpenSSH port (or ports)
64+ sshport=" $( $BIN /v-list-sys-sshd-port plain | sed ' :a;N;$!ba;s/\n/,/g' ) "
65+ if echo " $sshport " | grep -E ' ^[0-9]+(,[0-9]+)*$' & > /dev/null; then
66+ sed -i -E " s/(PORT=')[0-9]+(,[0-9]+)*('.*COMMENT='SSH')/\1$sshport \3/" $rules
67+ sed -i " /CHAIN='SSH'/c\CHAIN='SSH' PORT='$sshport ' PROTOCOL='TCP'" " $HESTIA /data/firewall/chains.conf"
6768fi
6869
6970# Load ipset lists before adding Hestia iptables rules
You can’t perform that action at this time.
0 commit comments