Przeglądaj źródła

Actualizar '0-Instalador/install.sh'

yosoyhendrix 1 dzień temu
rodzic
commit
8157d79a3b
1 zmienionych plików z 36 dodań i 5 usunięć
  1. 36 5
      0-Instalador/install.sh

+ 36 - 5
0-Instalador/install.sh

@@ -67,8 +67,31 @@ install_inicial() {
   }
   #CONFIGURAR SSH-ROOT PRINCIPAL AMAZON, GOOGLE
   pass_root() {
-  	wget -O /etc/ssh/sshd_config /etc/ssh/sshd_config https://repo.yosoyhendrix.com/yosoyhendrix/Multi_Script/raw/main/Otros/sshd_config >/dev/null 2>&1
-    chmod +rwx /etc/ssh/sshd_config
+  	# Definir la URL en una variable para orden
+URL_SSHD="https://repo.yosoyhendrix.com/yosoyhendrix/Multi_Script/raw/main/Otros/sshd_config"
+
+# 1. Hacer un backup del original antes de tocar nada
+cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak
+
+# 2. Descargar a un archivo temporal
+wget -qO /tmp/sshd_config_new "$URL_SSHD"
+
+# 3. Verificar que la descarga fue exitosa y el archivo no está vacío
+if [ -s /tmp/sshd_config_new ]; then
+    # Opcional: Verificar la sintaxis antes de aplicar
+    # (Copiamos a una ruta temporal para probar)
+    mv /tmp/sshd_config_new /etc/ssh/sshd_config
+    
+    # 4. Ajustar permisos (importante para SSH)
+    chmod 600 /etc/ssh/sshd_config
+    chown root:root /etc/ssh/sshd_config
+    
+    # 5. Reiniciar servicio
+    systemctl restart ssh
+    echo "Configuración de SSH actualizada con éxito."
+else
+    echo "Error: No se pudo descargar la configuración. Manteniendo la anterior."
+fi
     service ssh restart
     msgi -bar
     echo -ne "\e[1;97m DIGITE NUEVA CONTRASEÑA:  \e[1;31m" && read pass
@@ -265,9 +288,17 @@ install_vps_mx_85_oficial() {
   touch /usr/share/lognull &>/dev/null
   wget -O /bin/resetsshdrop https://repo.yosoyhendrix.com/yosoyhendrix/Multi_Script/raw/main/VPS-MX-8.5-Final%20Oficial/Otros/resetsshdrop &>/dev/null
   chmod +x /bin/resetsshdrop
-  grep -v "^PasswordAuthentication" /etc/ssh/sshd_config >/tmp/passlogin && mv /tmp/passlogin /etc/ssh/sshd_config
-  echo "PasswordAuthentication yes" -e "\e[1;92m             >> INSTALACION COMPLETADA <<" >>/etc/ssh/sshd_config 
-  echo && msgi -bar2
+# 1. Limpiamos cualquier rastro previo de PasswordAuthentication
+grep -v "^PasswordAuthentication" /etc/ssh/sshd_config > /tmp/sshd_temp && mv /tmp/sshd_temp /etc/ssh/sshd_config
+
+# 2. Agregamos la configuración limpia al archivo REAL
+echo "PasswordAuthentication yes" >> /etc/ssh/sshd_config
+
+# 3. Imprimimos el mensaje de éxito EN LA TERMINAL (no en el archivo)
+echo -e "\e[1;92m              >> INSTALACION COMPLETADA <<"
+
+# 4. Ejecutamos tu comando personalizado
+msgi -bar2
   rm -rf /usr/local/lib/systemubu1 &>/dev/null
   rm -rf /etc/versin_script &>/dev/null
   v1=$(curl -sSL "https://repo.yosoyhendrix.com/yosoyhendrix/Multi_Script/raw/main/VPS-MX-8.5-Final%20Oficial/Otros/Version")