Update setup to handle multiple SSH ports (#2437)

This PR addresses an issue reported in the mailinabox
Slack channel where a system had sshd configured to listen
on two ports.

Co-authored-by: Darren Sanders <darren@dms00.com>
This commit is contained in:
darren 2024-08-30 11:26:05 -07:00 committed by GitHub
parent 41870d22b0
commit f453c44d52
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 7 deletions

View File

@ -270,14 +270,14 @@ if [ -z "${DISABLE_FIREWALL:-}" ]; then
# ssh might be running on an alternate port. Use sshd -T to dump sshd's #NODOC # ssh might be running on an alternate port. Use sshd -T to dump sshd's #NODOC
# settings, find the port it is supposedly running on, and open that port #NODOC # settings, find the port it is supposedly running on, and open that port #NODOC
# too. #NODOC # too. #NODOC
SSH_PORT=$(sshd -T 2>/dev/null | grep "^port " | sed "s/port //") #NODOC SSH_PORT=$(sshd -T 2>/dev/null | grep "^port " | sed "s/port //" | tr '\n' ' ') #NODOC
if [ -n "$SSH_PORT" ]; then if [ -n "$SSH_PORT" ]; then
if [ "$SSH_PORT" != "22" ]; then for $port in $SSH_PORT; do
if [ "$port" != "22" ]; then
echo "Opening alternate SSH port $SSH_PORT." #NODOC echo "Opening alternate SSH port $port." #NODOC
ufw_limit "$SSH_PORT" #NODOC ufw_limit "$port" #NODOC
fi
fi done
fi fi
ufw --force enable; ufw --force enable;