# Cloud PC join-tailnet one-shot setup (agent2/agent3, same recipe as agent1) # Run as Administrator in PowerShell on the TeleAgent cloud PC. # Does: no-sleep, install Tailscale, install OpenSSH (GitHub Win32-OpenSSH), # install Muse public key, firewall+autostart, create C:\share, report status. # It does NOT log into Tailscale - that Microsoft-account login is a manual step after this script. $ErrorActionPreference = 'Continue' [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 Write-Host '== 1. Disable sleep / hibernate ==' powercfg /change standby-timeout-ac 0 powercfg /change monitor-timeout-ac 0 powercfg /change hibernate-timeout-ac 0 Write-Host '== 2. Install Tailscale (skip if present) ==' $ts = 'C:\Program Files\Tailscale\tailscale.exe' if (Test-Path $ts) { Write-Host 'Tailscale already installed' } else { $msi = "$env:TEMP\tailscale-setup-amd64.msi" $ok = $false foreach ($u in @('https://pkgs.tailscale.com/stable/tailscale-setup-1.104.7-amd64.msi','https://pkgs.tailscale.com/stable/tailscale-setup-latest-amd64.msi')) { try { Invoke-WebRequest $u -OutFile $msi; if ((Get-Item $msi).Length -gt 1000000) { $ok = $true; break } } catch { Write-Host ('download failed: ' + $u) } } if (-not $ok) { throw 'Tailscale installer download failed' } Start-Process msiexec.exe -ArgumentList "/i `"$msi`" /quiet /norestart" -Wait } Start-Service Tailscale -ErrorAction SilentlyContinue Set-Service -Name Tailscale -StartupType Automatic -ErrorAction SilentlyContinue Write-Host '== 3. Install OpenSSH Server (skip if sshd present) ==' if (Get-Service sshd -ErrorAction SilentlyContinue) { Write-Host 'sshd already installed' } else { try { Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0 } catch { Write-Host 'Add-WindowsCapability failed, falling back to GitHub release' } } if (-not (Get-Service sshd -ErrorAction SilentlyContinue)) { $rels = Invoke-RestMethod 'https://api.github.com/repos/PowerShell/Win32-OpenSSH/releases?per_page=5' $url = $null foreach ($r in $rels) { $a = $r.assets | Where-Object { $_.name -eq 'OpenSSH-Win64.zip' } if ($a) { $url = $a.browser_download_url; break } } if (-not $url) { throw 'OpenSSH-Win64.zip asset not found' } $zip = "$env:TEMP\OpenSSH-Win64.zip" Invoke-WebRequest $url -OutFile $zip Expand-Archive $zip -DestinationPath 'C:\Program Files' -Force powershell -ExecutionPolicy Bypass -File 'C:\Program Files\OpenSSH-Win64\install-sshd.ps1' } New-NetFirewallRule -Name 'OpenSSH-Server-In-TCP' -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22 -ErrorAction SilentlyContinue Set-Service -Name sshd -StartupType Automatic Start-Service sshd Write-Host '== 4. Install Muse public key (admin accounts) ==' $k = 'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKainUS01NUA+p8FVdh2mNSEj5ZQVf+q6DVKbxVn5iwN hatch' $f = 'C:\ProgramData\ssh\administrators_authorized_keys' $k | Out-File -Encoding ascii -FilePath $f icacls $f /inheritance:r /grant 'SYSTEM:F' /grant 'Administrators:F' Restart-Service sshd Write-Host '== 5. Shared exchange folder ==' New-Item -ItemType Directory -Force -Path 'C:\share','C:\share\inbox','C:\share\outbox' | Out-Null Write-Host '== 6. Report ==' Write-Host ('hostname: ' + (hostname)) Write-Host ('whoami: ' + (whoami)) Get-Service sshd, Tailscale | Format-Table Name, Status, StartType if (Test-Path $ts) { & $ts status; & $ts ip } Write-Host 'DONE - next step: log into Tailscale with the Microsoft account (same one as agent1)'