firewall.sh 694 B

1234567891011121314151617181920212223242526272829
  1. #!/bin/sh
  2. # TODO check if root
  3. echo -e '\033[35m
  4. ______________ _______ _____ __ __
  5. / ____/ _/ __ \/ ____/ | / / | / / / /
  6. / /_ / // /_/ / __/ | | /| / / /| | / / / /
  7. / __/ _/ // _, _/ /___ | |/ |/ / ___ |/ /___/ /___
  8. /_/ /___/_/ |_/_____/ |__/|__/_/ |_/_____/_____/
  9. \033[0m'
  10. echo -e "\033[35;1mInstalling ufw and setup firewall (allowing only ssh and http) \033[0m"
  11. if [ "$EUID" -ne 0 ]; then
  12. echo "Please run as root"
  13. exit
  14. fi
  15. sleep 2
  16. apt-get --yes install ufw
  17. ufw allow ssh
  18. ufw allow http
  19. ufw allow https
  20. # TODO ask for allowing ssh for some ip
  21. ufw enable
  22. ufw status verbose
  23. echo -e "\033[92;1mufw installed and firwall configured\033[Om"