senharoot.ssh 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #!/bin/bash
  2. clear
  3. [[ "$(whoami)" != "root" ]] && {
  4. clear
  5. echo -e "\033[1;31mExeculte como usuario root, \033[1;32m(\033[1;37msudo -i\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 81 -j ACCEPT
  29. iptables -A INPUT -p tcp --dport 80 -j ACCEPT
  30. iptables -A INPUT -p tcp --dport 443 -j ACCEPT
  31. iptables -A INPUT -p tcp --dport 8799 -j ACCEPT
  32. iptables -A INPUT -p tcp --dport 8080 -j ACCEPT
  33. iptables -A INPUT -p tcp --dport 1194 -j ACCEPT
  34. echo -e "\033[1;31mAtencao!!\033[0m"
  35. echo " "
  36. echo -e "\033[1;37mEssa senha sera usada para entrar no seu servidor
  37. \033[0m"
  38. echo -ne "\033[1;32mDefina a senha root\033[1;37m: "; read senha
  39. [[ -z "$senha" ]] && {
  40. echo -e "\n\033[1;31mSenha invalida !\033[0m"
  41. exit 0
  42. }
  43. echo "root:$senha" | chpasswd
  44. echo -e "\n\033[1;31m[ \033[1;37mok ! \033[1;31m]\033[1;37m - \033[1;32mSenha definida ! \033[0m"