root-pass.sh 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #!/bin/sh
  2. #Autor: Henry Chumo
  3. #Alias : ChumoGH
  4. source <(curl -sL https://raw.githubusercontent.com/ChumoGH/ChumoGH-Script/master/msg-bar/msg)
  5. rootpass () {
  6. clear
  7. [[ "$(whoami)" != "root" ]] && {
  8. clear
  9. echo -e "\033[1;31mEXECULTE COMO USUARIO ROOT, \033[1;32m(\033[1;33msudo -i\033[1;32m)\033[0m"
  10. exit
  11. }
  12. unset yesno
  13. [[ -e /root/name ]] && figlet -p -f smslant < /root/name | lolcat || echo -e "\033[7;49;35m ${TTini} New ChumoGH${TTcent}VPS ${TTfin} "
  14. msg -bar
  15. [[ $(uname -m 2> /dev/null) != x86_64 ]] && {
  16. msg -bar
  17. echo -e " PROCESADOR ARM DETECTADO "
  18. }
  19. echo -e "${cor[5]} ESTA HERRAMIENTA LIBERA ACCESO root EN VPS "
  20. echo -e "${cor[4]} ESPECIAL PARA (AWS,GOOGLE,AZURE,ETC)
  21. PRESIONA S, CASO CONTRARIO, PRESIONA N"
  22. echo -ne "\033[1;32m ESTAS SEGURO? [S/N]: "; read yesno
  23. while [[ ${yesno} != @(s|S|y|Y|n|N) ]]; do
  24. read -p "[S/N]: " yesno
  25. tput cuu1 && tput dl1
  26. done
  27. if [[ ${yesno} = @(s|S|y|Y) ]]; then
  28. #Parametros Aplicados
  29. echo " RESPALDANDO AJUSTES PREVIOS "
  30. echo '#######CONFIG NATURAL' >> /bin/ejecutar/sshd_config
  31. cat /etc/ssh/sshd_config >> /bin/ejecutar/sshd_config
  32. #Inicia Procedimentos
  33. echo -e "\033[1;33mAPLICANDO CONFIGURACIONES"
  34. fun_bar
  35. #[[ $(uname -m 2> /dev/null) != x86_64 ]] &&
  36. apt purge netfilter-persistent -y &> /dev/null
  37. [[ $(grep -c "prohibit-password" /etc/ssh/sshd_config) != '0' ]] && {
  38. sed -i "s/prohibit-password/yes/g" /etc/ssh/sshd_config
  39. } > /dev/null
  40. [[ $(grep -c "without-password" /etc/ssh/sshd_config) != '0' ]] && {
  41. sed -i "s/without-password/yes/g" /etc/ssh/sshd_config
  42. } > /dev/null
  43. [[ $(grep -c "#PermitRootLogin" /etc/ssh/sshd_config) != '0' ]] && {
  44. sed -i "s/#PermitRootLogin/PermitRootLogin/g" /etc/ssh/sshd_config
  45. } > /dev/null
  46. [[ $(grep -c "PasswordAuthentication" /etc/ssh/sshd_config) = '0' ]] && {
  47. echo 'PasswordAuthentication yes' > /etc/ssh/sshd_config
  48. } > /dev/null
  49. [[ $(grep -c "PasswordAuthentication no" /etc/ssh/sshd_config) != '0' ]] && {
  50. sed -i "s/PasswordAuthentication no/PasswordAuthentication yes/g" /etc/ssh/sshd_config
  51. } > /dev/null
  52. [[ $(grep -c "#PasswordAuthentication no" /etc/ssh/sshd_config) != '0' ]] && {
  53. sed -i "s/#PasswordAuthentication no/PasswordAuthentication yes/g" /etc/ssh/sshd_config
  54. } > /dev/null
  55. #sed -i "s;#PasswordAuthentication;PasswordAuthentication yes;g" /etc/ssh/sshd_config
  56. echo -e ' '
  57. echo -ne " \033[1;31m[ ! ] Services ssh restart"
  58. service ssh restart > /dev/null 2>&1
  59. [[ -e /etc/init.d/ssh ]] && /etc/init.d/ssh restart > /dev/null 2>&1 && echo -e "\033[1;32m [OK]" || echo -e "\033[1;31m [FAIL]"
  60. echo -e ' '
  61. echo -e " INGRESA TU PASS PARA LIBERAR ROOT"
  62. read -p " NUEVA CONTRASEÑA : " pass
  63. tput cuu1 && tput dl1
  64. tput cuu1 && tput dl1
  65. echo -e " INGRESA NUEVAMENTE TU CONTRASEÑA "
  66. read -p " REPITE TU PASSWD : " pass1
  67. tput cuu1 && tput dl1
  68. tput cuu1 && tput dl1
  69. [[ $pass != $pass1 ]] && echo "CONTRASEÑAS INVALIDAS, REINTENTA !!" && return
  70. (echo $pass; echo $pass)|passwd 2>/dev/null
  71. fun_bar
  72. echo -e "${cor[3]} Configuraciones aplicadas con exito !"
  73. echo -e " Recuerda Acceder con la identidad ROOT la proxima Entrada"
  74. echo -e "${cor[2]} Su contraseña root ahora es : ${cor[4]}$pass"
  75. service ssh restart > /dev/null 2>&1
  76. service sshd restart > /dev/null 2>&1
  77. fi
  78. msg -bar
  79. read -p "PRESIONA ENTER PARA FINALIZAR"
  80. msg -bar
  81. }
  82. rootpass