Skip to content

Commit c65df89

Browse files
committed
Make firewall script more general
1 parent 9bbe859 commit c65df89

File tree

3 files changed

+33
-23
lines changed

3 files changed

+33
-23
lines changed

security/firewall.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash -e
2+
3+
if [ "${EUID}" -ne 0 ]; then
4+
echo "This script should be run as root."
5+
exit 1
6+
fi
7+
8+
if command -v mosh &> /dev/null; then
9+
ufw allow mosh comment "Mosh"
10+
fi
11+
12+
ufw allow ssh comment "SSH"
13+
14+
if command -v syncthing &> /dev/null; then
15+
ufw allow 22000/tcp comment "Syncthing"
16+
ufw allow 21027/udp comment "Syncthing Discovery"
17+
18+
while true; do
19+
read -p "Do you want to allow Syncthing remote GUI access? (y/n) " yn
20+
21+
case $yn in
22+
[yY] ) echo "Enabling remote GUI access"
23+
ufw allow 8384 comment "Syncthing GUI"
24+
break;;
25+
[nN] ) echo "Skipping remote GUI access"
26+
exit;;
27+
* ) echo "Invalid response";;
28+
esac
29+
done
30+
fi
31+
32+
ufw enable

security/syncthing_firewall.sh

Lines changed: 0 additions & 22 deletions
This file was deleted.

ssh/setup_ssh_server.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ systemctl restart ssh
1616

1717
if command -v &> /dev/null; then
1818
echo "Creating UFW firewall rule and enabling UFW."
19-
ufw allow ssh comment SSH
19+
ufw allow ssh comment "SSH"
2020
ufw enable
2121
else
2222
echo "UFW was not found."

0 commit comments

Comments
 (0)