# get.ps1 - kick-off for SSNY mesh nodes on Windows. # # irm https://get.success.build | iex # # Run from any PowerShell window on the new machine (it does not need to be elevated; it asks for # elevation itself). It shows the target, downloads the committed stage script from the same # public folder, refuses it unless its SHA256 matches the hash pinned below at publish time, # runs it elevated, and prints the result. # # Source of truth: ssny-us/systems scripts/bootstrap/get.ps1 (private repo). Published by # scripts/publish-node-bootstrap.sh, which fills in the manifest below from the repo and checks # the live copies after upload. No secrets here or in any stage file: auth keys are typed at the # prompt and never stored. Refs: systems#535 (Windows onboarding), systems#733 (kick-off). # # Linux/macOS: curl -fsSL https://get.success.build | sh $ErrorActionPreference = 'Stop' $ProgressPreference = 'SilentlyContinue' [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 $Base = 'https://success.build/bootstrap' $Published = '2026-12-05T12:30Z systems@a191316b0' # name | sha256 (filled at publish time; a '__' placeholder means unpublished source: refuse to run) $Manifest = @' windows_mesh-bootstrap.ps1 | dfbad3f710bbe9cc93ec48698bf131ed68040e301c4ef9f6bca5cfb98a39cff7 windows_stay-awake-on-ac.ps1 | 1e16ea6d7084bae60078dfe8f3f2c2a5b6a67648950812e6abbb615297bc54de windows_standard-apps.ps1 | d62c413c76f36b0fbf438bfe5b3f048ae2cdd50c423a2e61decde05a8abcf932 windows_setup-wsl2.ps1 | 05340a6359897a1013dc4338539fad9c4cc1a2dfcf03664401260a31f05d2ceb windows_rustdesk-remote-ready.ps1 | ec8a2e34e4b25837166f8221e8411af2a48daad51de88cc809b72525d0206913 windows_wsl-for-user.ps1 | c26756c9679274bcd3da1a5965285f047c090574ee9aec05f6edcf47e0ed8a1e mesh_add-node.sh | f24423d6b968cbb78b3b8abc451f675f5d4bf89b1ca30f2ed9fa0fecafc12948 linux_stay-awake.sh | e63464f22a24c571de848633dfa3ad6e0905b966f620c85d97a7e1c80ca9977f linux_standard-apps.sh | 421533fc8d098a18cf78799c5e709ae8c76ac985494605409bbbf3cfcd86de2d linux_rustdesk-sudoers.sh | 0a2ffce24b5fed9e6ba5c439f4877e3ace2ad468adb32cca938c8387da704d37 windows_onboard-mesh.ps1 | 8103a409fc3b4d2b98612ca5e3c79f42e7110a02f6e81d717d9aacf5b518f584 windows_enable-mesh-ssh.ps1 | 5ed1eec5c171b6edb6985ae23d89b0995d4f578d3546af4c8352853544b9bbc2 windows_setup-operator-ssh.ps1 | af91274c35ea67d170940ede1853fb1ed50548406d40a634f5bb27d307948f4a config/sublime/User/Preferences.sublime-settings | 6b2339ce572543f78ac3de4a251fb4e1168fa1484e92a2b4c73a61a29c3d4a3e '@ # Results report (systems#737): encrypted to this public key (RSA-3072 modulus, filled at publish time; empty # means reporting is off). Only a run given a join key reports; the report holds the stage results and, when a # stage did not finish OK, the end of its log. Never keys or passwords. $ReportKid = 'k202612' $ReportMod = 'vcjUMtiVD0frBl0Zd20DBqC4aA42Lis5wo4rNtAUzPN/jI/rZsodY5jHgah9QDv5prYJ1xlsNbtRaa7eu26Bn5VMB8qsvWnEaPcXXukxbEakXBftOFsvyqC7uGzN3NcbCw5ulK2oWKgfK++MqrGQRLzU1Nju22Nz1zOREmIZ+DYgBWkimyp+26z/62lAgoJN2pv/CoMACIWL6G0DqHNW8Y9mpN3Jan+6/MohLoL5/6JETgVLxKmXGspuwHtbxvJSrLw+1BRAFKlGCMlY21WXWxx9c5vx0z77j/ZlCmKelGzip8nGbg6jmrfaOZ4OFrJBiru2NYVfua3hrmMn+hikAGAEmq58TMEierFMT17oFRMcV3OvmCecdWHGZrXUCsmCFdzQPLCNJ71ELswpYkiCeBDUWUHwDcEop6u9v0bzydvU58gcgylrPmFDO1jd7NBNNtbyMCF8HOL1JBx2G54RRY9v/Jn0968705g6xhVZgStJKn6V9VKeQqJkLijxVKlz' $ReportUrl = 'https://get.success.build/report' # Targets this kick-off can reach. One row per role; the stage script owns the details and the verify. $Targets = @( [pscustomobject]@{ Key = '1'; Name = 'Mesh node'; Stage = 'windows_mesh-bootstrap.ps1'; Then = @('windows_stay-awake-on-ac.ps1', 'windows_standard-apps.ps1') What = 'On the SSNY mesh (Headscale, unattended, no tray app) and reachable by the fleet over SSH, mesh-only, kept awake on AC power, then the standard apps (Sublime Text, Obsidian, RustDesk on our relay, WSL Ubuntu). Asks for a mesh name, and a one-time key only if it is not on the mesh yet.' } ) function Hash($name) { foreach ($line in ($Manifest -split "`n")) { $p = $line.Trim() -split '\s*\|\s*' if ($p.Count -eq 2 -and $p[0] -eq $name) { return $p[1].ToLower() } } return $null } Write-Host '' Write-Host 'SSNY mesh node bootstrap' -ForegroundColor Cyan Write-Host " published $Published | this machine: $env:COMPUTERNAME ($([Environment]::OSVersion.VersionString))" if ($Manifest -match ('__' + 'MANIFEST' + '__') -or $Published -match '__') { throw 'This is the unpublished source of get.ps1 (no pinned hashes). Use the published copy at https://success.build/bootstrap/get.ps1' } if ($PSVersionTable.PSEdition -eq 'Core' -and -not $IsWindows) { Write-Host 'This is not Windows. Use: curl -fsSL https://get.success.build | sh' -ForegroundColor Yellow return } Write-Host '' foreach ($t in $Targets) { Write-Host (" [{0}] {1}: {2}" -f $t.Key, $t.Name, $t.What) } $pick = if ($Targets.Count -eq 1) { $Targets[0].Key } else { Read-Host 'Target' } $target = $Targets | Where-Object Key -eq $pick if (-not $target) { throw "no target '$pick'" } $dir = Join-Path $env:ProgramData 'mesh\bootstrap' New-Item -ItemType Directory -Path $dir -Force | Out-Null # Download and verify every stage before anything runs; a mismatch stops the whole run. function Fetch($name) { $f = Join-Path $dir $name $want = Hash $name if (-not $want) { throw "no pinned hash for $name" } Invoke-WebRequest -Uri "$Base/$name" -OutFile $f -UseBasicParsing $got = (Get-FileHash $f -Algorithm SHA256).Hash.ToLower() if ($got -ne $want) { Remove-Item $f -Force -ErrorAction SilentlyContinue; throw "SHA256 mismatch for ${name}: got $got, pinned $want. Not running it." } Write-Host " $name verified (sha256 $($got.Substring(0,16))...)" -ForegroundColor Green return $f } Write-Host '' $file = Fetch $target.Stage # Later stages run in order, after the mesh setup. windows_standard-apps.ps1 gets the pinned manifest. $then = @(foreach ($t in @($target.Then)) { if ($t) { Fetch $t } }) # The pinned manifest goes along, so later stages verify their own helper files against it. $manFile = Join-Path $dir 'manifest-pinned.txt' Set-Content -Path $manFile -Value $Manifest -Encoding ASCII $tokFile = Join-Path $env:ProgramData 'mesh\report-token.txt' $runStart = (Get-Date).ToUniversalTime() $results = @( @{ Path = (Join-Path $env:ProgramData 'mesh\bootstrap-result.json'); Label = 'mesh' }, @{ Path = (Join-Path $env:ProgramData 'mesh\apps-result.json'); Label = 'apps' } ) foreach ($r in $results) { $r.Before = if (Test-Path $r.Path) { (Get-Item $r.Path).LastWriteTimeUtc } else { [datetime]::MinValue } } # One elevated session runs the stages in order; the next stage runs only if the mesh setup did not FAIL. $rf = $results[0].Path $run = "`$rf = '$rf'; `$b = if (Test-Path `$rf) { (Get-Item `$rf).LastWriteTimeUtc } else { [datetime]::MinValue }`n" $run += "& '$file'`n" if ($then) { $run += "`$r = `$null; if ((Test-Path `$rf) -and (Get-Item `$rf).LastWriteTimeUtc -gt `$b) { try { `$r = Get-Content `$rf -Raw | ConvertFrom-Json } catch {} }`n" $steps = ($then | ForEach-Object { if ($_ -match 'standard-apps') { "& '$_' -ManifestFile '$manFile'" } else { "& '$_'" } }) -join '; ' $run += "if (`$r -and `$r.result -ne 'FAIL') { $steps } else { Write-Host 'Later stages skipped: the mesh setup did not finish OK.' -ForegroundColor Yellow }`n" } $enc = [Convert]::ToBase64String([Text.Encoding]::Unicode.GetBytes($run)) $argv = @('-NoProfile', '-ExecutionPolicy', 'Bypass', '-EncodedCommand', $enc) $isAdmin = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole( [Security.Principal.WindowsBuiltInRole]::Administrator) if ($isAdmin) { & powershell.exe @argv } else { Write-Host ' Opening an elevated window for the setup (approve the Windows prompt). Answer its questions there;' -ForegroundColor Yellow Write-Host ' it closes by itself when done and the result shows here.' -ForegroundColor Yellow $p = Start-Process powershell.exe -Verb RunAs -ArgumentList $argv -PassThru $p.WaitForExit() } $shown = 0 foreach ($r in $results) { if ((Test-Path $r.Path) -and (Get-Item $r.Path).LastWriteTimeUtc -gt $r.Before) { $j = Get-Content $r.Path -Raw | ConvertFrom-Json $c = @{ OK = 'Green'; WARN = 'Yellow'; FAIL = 'Red' }[$j.result] Write-Host '' Write-Host "RESULT ($($r.Label)): $($j.result) ($($j.host), mesh IP $($j.mesh_ip))" -ForegroundColor $c $j.checks.PSObject.Properties | ForEach-Object { Write-Host (" {0,-12} {1}" -f $_.Name, $_.Value) } Write-Host " log: $($j.log)" $shown++ } } if (-not $shown) { Write-Host ''; Write-Host 'No new result was written; the setup window may have been closed early. Re-run the same command; it is safe to repeat.' -ForegroundColor Yellow } # --- Report the results to SSNY (encrypted; systems#737) ------------------------------------------------ function Seal([string]$json) { $rsa = $null try { $rsa = New-Object System.Security.Cryptography.RSACng } catch { $rsa = [System.Security.Cryptography.RSA]::Create() } $prm = New-Object System.Security.Cryptography.RSAParameters $prm.Modulus = [Convert]::FromBase64String($ReportMod); $prm.Exponent = [Convert]::FromBase64String('AQAB') $rsa.ImportParameters($prm) $k = New-Object byte[] 64; [Security.Cryptography.RandomNumberGenerator]::Create().GetBytes($k) $ek = $rsa.Encrypt($k, [Security.Cryptography.RSAEncryptionPadding]::OaepSHA256) $aes = [Security.Cryptography.Aes]::Create() $aes.Mode = [Security.Cryptography.CipherMode]::CBC; $aes.Padding = [Security.Cryptography.PaddingMode]::PKCS7 $aes.Key = [byte[]]$k[0..31]; $aes.GenerateIV() $pt = [Text.Encoding]::UTF8.GetBytes($json) $ct = $aes.CreateEncryptor().TransformFinalBlock($pt, 0, $pt.Length) $hm = New-Object Security.Cryptography.HMACSHA256 -ArgumentList (, [byte[]]$k[32..63]) $mac = $hm.ComputeHash([byte[]]($aes.IV + $ct)) [ordered]@{ v = 1; kid = $ReportKid; ek = [Convert]::ToBase64String($ek); iv = [Convert]::ToBase64String($aes.IV) ct = [Convert]::ToBase64String($ct); mac = [Convert]::ToBase64String($mac) } | ConvertTo-Json -Compress } function LogTail([string]$path, [int]$n = 80) { if ($path -and (Test-Path $path)) { try { return ((Get-Content $path -Tail $n -ErrorAction Stop) -join "`n") } catch {} } return '' } $token = $null if ((Test-Path $tokFile) -and (Get-Item $tokFile).LastWriteTimeUtc -gt $runStart) { $token = (Get-Content $tokFile -Raw).Trim() } if ($ReportMod -notmatch '^__' -and $ReportMod -and $token -match '^[0-9a-f]{40}$') { $runId = [guid]::NewGuid().ToString(); $seq = 0; $sent = 0 $reports = @() foreach ($r in $results) { if ((Test-Path $r.Path) -and (Get-Item $r.Path).LastWriteTimeUtc -gt $r.Before) { $j = Get-Content $r.Path -Raw | ConvertFrom-Json $tail = if ($j.result -ne 'OK') { LogTail $j.log } else { '' } $reports += , @($r.Label, "$($j.result)", $j, $tail, "$($j.host)") } } if (-not $reports) { $lg = Get-ChildItem (Join-Path $env:ProgramData 'mesh\reports') -Filter 'bootstrap-*.log' -ErrorAction SilentlyContinue | Sort-Object LastWriteTime -Descending | Select-Object -First 1 $reports += , @('run', 'NONE', $null, $(if ($lg) { LogTail $lg.FullName } else { '' }), '') } foreach ($x in $reports) { $seq++ $msg = [ordered]@{ v = 1; token = $token; run = $runId; seq = $seq; ts = (Get-Date).ToUniversalTime().ToString('yyyy-MM-ddTHH:mm:ssZ') computer = $env:COMPUTERNAME; mesh_name = $x[4]; label = $x[0]; result = $x[1]; doc = $x[2]; log_tail = $x[3] } try { $body = Seal ($msg | ConvertTo-Json -Depth 6 -Compress) [void](Invoke-RestMethod -Uri $ReportUrl -Method Post -Body $body -ContentType 'application/json' -TimeoutSec 20 -UseBasicParsing) $sent++ } catch { Write-Host " (report $($x[0]) not sent: $($_.Exception.Message))" -ForegroundColor DarkGray } } if ($sent) { Write-Host ''; Write-Host "Results sent to SSNY (encrypted): $sent report(s). Nothing to copy back." -ForegroundColor Green } Remove-Item $tokFile -Force -ErrorAction SilentlyContinue }