senharoot.sh 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/bin/bash
  2. clear
  3. [[ "$(whoami)" != "root" ]] && {
  4. clear
  5. echo -e "\033[1;31mExecute como usuário root, \033[1;32m(\033[1;37mdigite sudo su -\033[1;32m)\033[0m"
  6. exit
  7. }
  8. [[ $(grep -c "prohibit-password" /etc/ssh/sshd_config) != '0' ]] && {
  9. sed -i "s/prohibit-password/yes/g" /etc/ssh/sshd_config
  10. } > /dev/null
  11. [[ $(grep -c "without-password" /etc/ssh/sshd_config) != '0' ]] && {
  12. sed -i "s/without-password/yes/g" /etc/ssh/sshd_config
  13. } > /dev/null
  14. [[ $(grep -c "#PermitRootLogin" /etc/ssh/sshd_config) != '0' ]] && {
  15. sed -i "s/#PermitRootLogin/PermitRootLogin/g" /etc/ssh/sshd_config
  16. } > /dev/null
  17. [[ $(grep -c "PasswordAuthentication" /etc/ssh/sshd_config) = '0' ]] && {
  18. echo 'PasswordAuthentication yes' > /etc/ssh/sshd_config
  19. } > /dev/null
  20. [[ $(grep -c "PasswordAuthentication no" /etc/ssh/sshd_config) != '0' ]] && {
  21. sed -i "s/PasswordAuthentication no/PasswordAuthentication yes/g" /etc/ssh/sshd_config
  22. } > /dev/null
  23. [[ $(grep -c "#PasswordAuthentication no" /etc/ssh/sshd_config) != '0' ]] && {
  24. sed -i "s/#PasswordAuthentication no/PasswordAuthentication yes/g" /etc/ssh/sshd_config
  25. } > /dev/null
  26. service ssh restart > /dev/null
  27. iptables -F
  28. iptables -A INPUT -p tcp --dport 80 -j ACCEPT
  29. iptables -A INPUT -p tcp --dport 443 -j ACCEPT
  30. iptables -A INPUT -p tcp --dport 8080 -j ACCEPT
  31. iptables -A INPUT -p tcp --dport 1194 -j ACCEPT
  32. echo -e "\033[1;31mAtenção!!\033[0m"
  33. echo " "
  34. echo -e "\033[1;37mEssa senha sera usada para entrar no seu servidor
  35. \033[0m"
  36. echo -ne "\033[1;32mDefinir/alterar a senha root\033[1;37m: "; read senha
  37. [[ -z "$senha" ]] && {
  38. echo -e "\n\033[1;31mSenha invalida !\033[0m"
  39. exit 0
  40. }
  41. echo "root:$senha" | chpasswd
  42. echo -e "\n\033[1;31m[ \033[1;37mok ! \033[1;31m]\033[1;37m - \033[1;32mSenha definida ! \033[0m"