Guest User

Untitled

a guest
Jan 17th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. systemctl stop firewalld
  4. systemctl mask firewalld
  5. #setenforce 0
  6. yum install -y epel-release
  7. yum install -y fail2ban iptables-services
  8.  
  9. IPTABLES_CONF=/etc/sysconfig/iptables
  10. SSH_JAIL_CONF=/etc/fail2ban/jail.d/ssh.conf
  11.  
  12. sed -i '$d' $IPTABLES_CONF
  13. cat << EOF >> $IPTABLES_CONF
  14. -A INPUT -p tcp -m state --state NEW -m tcp --dport 443 -j ACCEPT
  15. -A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
  16. -A INPUT -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT
  17. -A INPUT -p tcp -m state --state NEW -m tcp --dport 2222 -j ACCEPT
  18. -A INPUT -p tcp -m state --state NEW -m tcp --dport 4433 -j ACCEPT
  19. COMMIT
  20. EOF
  21.  
  22. cat << EOF > $SSH_JAIL_CONF
  23. [ssh-iptables]
  24.  
  25. enabled = true
  26. filter = sshd
  27. action = iptables[name=SSH, port=ssh, protocol=tcp]
  28. sendmail-whois[name=SSH, dest=root, sender=fail2ban@example.com, sendername="Fail2Ban"]
  29. logpath = /var/log/secure
  30. maxretry = 5
  31. bantime = 86400
  32. EOF
  33.  
  34. systemctl start iptables
  35. systemctl enable iptables
  36.  
  37. systemctl start fail2ban
  38. systemctl enable fail2ban
Add Comment
Please, Sign In to add comment