41 lines
1.4 KiB
PowerShell
41 lines
1.4 KiB
PowerShell
function Log($msg) {
|
|
Write-Host $msg -ForegroundColor Cyan
|
|
if ($WZ_HOST) {
|
|
try {
|
|
Invoke-RestMethod -Uri "http://${WZ_HOST}/log" -Method Post -Body @{msg=$msg} -UseBasicParsing -ErrorAction SilentlyContinue | Out-Null
|
|
} catch {}
|
|
}
|
|
}
|
|
|
|
Log "=========================================="
|
|
Log " REPARANDO PERMISOS E INICIANDO SSHD "
|
|
Log "=========================================="
|
|
|
|
Log "1) Bypass ExecutionPolicy para FixHostFilePermissions..."
|
|
try {
|
|
# Cambiamos la politica solo para este proceso
|
|
Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process -Force
|
|
$out = & "C:\OpenSSH-Win64\FixHostFilePermissions.ps1" -Confirm:$false 2>&1
|
|
foreach ($line in $out) { Log " -> $line" }
|
|
Log "Script de permisos finalizado."
|
|
} catch {
|
|
Log "Error ejecutando script de permisos: $_"
|
|
}
|
|
|
|
Log "2) Iniciando servicio sshd..."
|
|
try {
|
|
Start-Service sshd -ErrorAction Stop
|
|
$svc = Get-Service sshd
|
|
Log "Servicio sshd. Estado actual: $($svc.Status) !!"
|
|
} catch {
|
|
Log "Fallo al iniciar el servicio: $_"
|
|
Log "Ejecutando sshd.exe -t para ver el error real de config:"
|
|
$test = & "C:\OpenSSH-Win64\sshd.exe" -t 2>&1
|
|
foreach ($line in $test) { Log " sshd -t: $line" }
|
|
}
|
|
|
|
Log "=========================================="
|
|
Log " FIN REPARACION "
|
|
Log "=========================================="
|
|
return
|