MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / windowsUserData

Function windowsUserData

e2e/src/vm/ec2.ts:192–204  ·  view source on GitHub ↗
(publicKey: string)

Source from the content-addressed store, hash-verified

190/** PowerShell user-data: enable OpenSSH, default the shell to PowerShell, and
191 * authorize our public key for the Administrator account. */
192const windowsUserData = (publicKey: string): string =>
193 [
194 "<powershell>",
195 "Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0",
196 "Set-Service -Name sshd -StartupType Automatic",
197 "Start-Service sshd",
198 "New-ItemProperty -Path 'HKLM:\\SOFTWARE\\OpenSSH' -Name DefaultShell -Value 'C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe' -PropertyType String -Force",
199 "New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22 -ErrorAction SilentlyContinue",
200 "$akf = 'C:\\ProgramData\\ssh\\administrators_authorized_keys'",
201 `Set-Content -Path $akf -Value '${publicKey}'`,
202 "icacls $akf /inheritance:r /grant 'Administrators:F' /grant 'SYSTEM:F'",
203 "</powershell>",
204 ].join("\n");
205
206const linuxUserData = (publicKey: string): string =>
207 ["#cloud-config", "ssh_authorized_keys:", ` - ${publicKey}`].join("\n");

Callers 1

ec2VmFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected