# ============================================================================ # GravitySense / Gravity fleet — New Desktop Bootstrap (Windows 11 Pro) # Build by Q-bot 2026-12-06. PREP DELIVERABLE — run ON the new desktop. # # One self-elevating run does: # 1. Re-launch elevated via UAC (if not already admin) # 2. Install Tailscale (winget MSI) + sign into Jefe's tailnet (interactive) # 3. Install OpenSSH Server (Add-WindowsCapability) # 4. Write the fleet pubkey to C:\ProgramData\ssh\administrators_authorized_keys # WITH the mandatory icacls ACL fix (sshd ignores the file otherwise) # 5. Restart sshd, set autostart # 6. Print back: tailnet IP, Windows username, hostname, sshd status # # The admin username is AUTO-DETECTED (no need to fill it in). # ============================================================================ [CmdletBinding()] param() $ErrorActionPreference = 'Stop' # ---- fleet pubkey (injected at build from vault/desktop-access/desktop_ed25519.pub) ---- $FLEET_PUB = 'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBvr7HxmiYcKzS0pgFb5V3tcdY2b/bb6F0JiBPdnm7LT openclaw-fleet-desktop-2026-12-06' # ---- self-elevate ---- $isAdmin = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent() ).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) if (-not $isAdmin) { Write-Host "Not elevated — restarting as Administrator (UAC prompt)..." $script = $MyInvocation.MyCommand.Definition $argsLine = $MyInvocation.BoundParameters.GetEnumerator() | ForEach-Object { "-$($_.Key) `"$($_.Value)`"" } $psArgs = '-NoProfile -ExecutionPolicy Bypass -File "' + $script + '" ' + $argsLine Start-Process -FilePath powershell.exe -Verb RunAs -ArgumentList $psArgs exit } Write-Host "=== Elevated OK ===" # ---- report functions ---- function Get-TailnetIP { $ts = 'C:\Program Files\Tailscale\tailscale.exe' if (Test-Path $ts) { try { return (& $ts ip -4 2>$null | Select-Object -First 1) } catch {} } return $null } # ---- 2) Tailscale install + login ---- $tsExe = 'C:\Program Files\Tailscale\tailscale.exe' if (-not (Test-Path $tsExe)) { Write-Host "[2] Installing Tailscale..." try { winget install --id Tailscale.Tailscale --accept-source-agreements --accept-package-agreements --silent -e | Out-Null } catch { Write-Warning "winget install failed ($_); downloading MSI fallback"; Invoke-WebRequest -Uri 'https://pkgs.tailscale.com/stable/tailscale-setup-latest-amd64.msi' -OutFile "$env:TEMP\tailscale.msi" Start-Process msiexec.exe -ArgumentList '/i', "$env:TEMP\tailscale.msi", '/qn', '/norestart' -Wait } } Write-Host "[2] Tailscale installed. Checking login..." $tsState = & $tsExe status 2>$null if ($LASTEXITCODE -ne 0 -or ($tsState -notmatch 'logged out')) { Write-Host " Tailscale needs login — a browser/auth window will open (sign in as eljefe@gravitybolivia.com tailnet, i.e. the SAME account as the Omen)." # interactively login; if a pre-auth key is ever provided, swap this line: # & $tsExe up --authkey '' & $tsExe up } else { Write-Host " Tailscale already logged in." } # ---- 3) OpenSSH Server ---- Write-Host "[3] Ensuring OpenSSH Server..." $sshdSvc = Get-Service sshd -ErrorAction SilentlyContinue if (-not $sshdSvc) { Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0 | Out-Null $sshdSvc = Get-Service sshd -ErrorAction SilentlyContinue } if ($sshdSvc) { Start-Service sshd Set-Service -Name sshd -StartupType 'Automatic' Write-Host "[3] sshd running + autostart ON." } else { Write-Error "OpenSSH Server failed to install." } # ---- 4) pubkey + ACL ---- Write-Host "[4] Writing fleet pubkey..." $akl = 'C:\ProgramData\ssh\administrators_authorized_keys' if (-not (Test-Path 'C:\ProgramData\ssh')) { New-Item -ItemType Directory -Path 'C:\ProgramData\ssh' -Force | Out-Null } # ensure trailing newline before append $existing = if (Test-Path $akl) { Get-Content $akl -Raw } else { '' } if ($existing -and -not $existing.EndsWith("`n")) { $existing += "`n" } if ($existing -match [regex]::Escape($FLEET_PUB)) { Write-Host "[4] Key already present — no change." } else { Set-Content -Path $akl -Value ($existing + $FLEET_PUB + "`n") -Encoding ascii # CRITICAL ACL: inheritable Administrators+SYSTEM only, else sshd refuses the file icacls $akl /inheritance:r /grant "Administrators:F" /grant "SYSTEM:F" | Out-Null # Explicitly remove inherited/forwarded ACEs on the parent for safety on some builds icacls 'C:\ProgramData\ssh' /inheritance:r /grant "Administrators:F" /grant "SYSTEM:F" | Out-Null Write-Host "[4] Key written + ACL hardened." } # ---- 5) restart sshd to pick up key ---- Write-Host "[5] Restarting sshd..." Restart-Service sshd -Force # ---- 6) report ---- Write-Host "" Write-Host "===================== BOOTSTRAP REPORT =====================" Write-Host ("Tailnet IP : {0}" -f (Get-TailnetIP)) Write-Host ("Windows user: {0}" -f $env:USERNAME) Write-Host ("Hostname : {0}" -f $env:COMPUTERNAME) Write-Host ("sshd status : {0}" -f (Get-Service sshd).Status) Write-Host ("sshd running: {0}" -f (Get-Process sshd -ErrorAction SilentlyContinue | Measure-Object | Select-Object -ExpandProperty Count)) Write-Host "=============================================================" Write-Host "" Write-Host "If Tailnet IP is blank, reopen Tailscale (tray) and re-login, then run:" Write-Host " `"C:\Program Files\Tailscale\tailscale.exe`" ip -4" Write-Host "Send the above report back to Q-bot to finish onboarding."