From 4e011e177cbde94862b872fa6196face3c9c63a3 Mon Sep 17 00:00:00 2001 From: Damian Myrda Date: Sat, 7 Sep 2024 17:46:19 -0500 Subject: [PATCH] Added firewall --- setup.sh | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/setup.sh b/setup.sh index bac50be..deb15c4 100755 --- a/setup.sh +++ b/setup.sh @@ -1,15 +1,5 @@ #!/bin/sh -echo "securing ssh" -PORT=2222 -sudo sed -i -e 's/^#\?PasswordAuthentication .*/PasswordAuthentication no/' \ - -e 's/^#\?PermitRootLogin .*/PermitRootLogin no/' \ - -e 's/^#\?UsePAM .*/UsePAM no/' \ - -e 's/^#\?Port .*/Port $PORT/' \ - /etc/ssh/sshd_config -echo "switched port to $PORT" -sudo systemctl restart sshd - echo "setting up services" docker compose build docker compose up mail -d @@ -20,3 +10,20 @@ docker compose exec -it mail setup config dkim docker exec -it mail cat /tmp/docker-mailserver/opendkim/keys/prime8.dev/mail.txt docker compose down echo "services are set up" + +echo "setting up firewall" +sudo ufw default deny incoming +sudo ufw defualt allow outgoing +sudo ufw allow 2222,80,443,25,143,465,587,993,22,9418/tcp +sudo ufw enable +echo "firewall set up" + +echo "securing ssh" +PORT=2222 +sudo sed -i -e 's/^#\?PasswordAuthentication .*/PasswordAuthentication no/' \ + -e 's/^#\?PermitRootLogin .*/PermitRootLogin no/' \ + -e 's/^#\?UsePAM .*/UsePAM no/' \ + -e 's/^#\?Port .*/Port $PORT/' \ + /etc/ssh/sshd_config +echo "switched port to $PORT" +sudo systemctl restart sshd -- 2.43.4