Remove standard SSH allow rules when disabling SSH
Reported-by: Sean Huber
This commit is contained in:
1 parent
d3cfd53b99
commit
09c2b28afa
1 file changed
+7
-4
@@ -1,6 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# omarchy:summary=Disable the OpenSSH server, close the firewall port, and optionally remove authorized keys
|
# omarchy:summary=Disable the OpenSSH server, remove standard firewall rules, and optionally remove authorized keys
|
||||||
# omarchy:requires-sudo=true
|
# omarchy:requires-sudo=true
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
@@ -13,9 +13,12 @@ echo "Stopping and disabling the OpenSSH server..."
|
|||||||
sudo systemctl disable --now sshd.service 2>/dev/null || true
|
sudo systemctl disable --now sshd.service 2>/dev/null || true
|
||||||
|
|
||||||
if omarchy-cmd-present ufw; then
|
if omarchy-cmd-present ufw; then
|
||||||
echo "Closing the SSH port in the firewall..."
|
echo "Removing standard SSH firewall rules..."
|
||||||
sudo ufw --force delete limit 22/tcp >/dev/null 2>&1 || true
|
sudo ufw --force delete limit 22/tcp >/dev/null
|
||||||
|
sudo ufw --force delete allow 22/tcp >/dev/null
|
||||||
|
sudo ufw --force delete allow ssh >/dev/null
|
||||||
sudo ufw reload >/dev/null
|
sudo ufw reload >/dev/null
|
||||||
|
echo "Standard SSH firewall rules removed. Review custom firewall rules separately."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -s $AUTHORIZED_KEYS ]]; then
|
if [[ -s $AUTHORIZED_KEYS ]]; then
|
||||||
@@ -28,5 +31,5 @@ if [[ -s $AUTHORIZED_KEYS ]]; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo -e "\e[32m\nThe SSH server has been disabled and its firewall port closed.\e[0m"
|
echo -e "\e[32m\nThe SSH server has been disabled.\e[0m"
|
||||||
echo "The openssh package remains installed since it also provides the ssh client."
|
echo "The openssh package remains installed since it also provides the ssh client."
|
||||||
Reference in new issue
Block a user