|
| 1 | +<?xml version="1.0" encoding="utf-8"?> |
| 2 | +<!-- Windows unattended answer file for Lima guest VMs (amd64). |
| 3 | + Ref: https://learn.microsoft.com/en-us/windows-hardware/manufacture/desktop/update-windows-settings-and-scripts-create-your-own-answer-file-sxs --> |
| 4 | +<unattend xmlns="urn:schemas-microsoft-com:unattend"> |
| 5 | + |
| 6 | + <!-- windowsPE: locale, disk layout, image selection, hw bypass --> |
| 7 | + <settings pass="windowsPE"> |
| 8 | + <component name="Microsoft-Windows-International-Core-WinPE" |
| 9 | + processorArchitecture="amd64" |
| 10 | + publicKeyToken="31bf3856ad364e35" |
| 11 | + language="neutral" |
| 12 | + versionScope="nonSxS" |
| 13 | + xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State"> |
| 14 | + <SetupUILanguage> |
| 15 | + <UILanguage>en-US</UILanguage> |
| 16 | + </SetupUILanguage> |
| 17 | + <InputLocale>en-US</InputLocale> |
| 18 | + <SystemLocale>en-US</SystemLocale> |
| 19 | + <UILanguage>en-US</UILanguage> |
| 20 | + <UserLocale>en-US</UserLocale> |
| 21 | + </component> |
| 22 | + |
| 23 | + <component name="Microsoft-Windows-Setup" |
| 24 | + processorArchitecture="amd64" |
| 25 | + publicKeyToken="31bf3856ad364e35" |
| 26 | + language="neutral" |
| 27 | + versionScope="nonSxS" |
| 28 | + xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State"> |
| 29 | + |
| 30 | + <!-- Bypass Win11 hardware checks (TPM, SecureBoot, RAM, etc.) — irrelevant in a VM --> |
| 31 | + <RunSynchronous> |
| 32 | + <RunSynchronousCommand wcm:action="add"> |
| 33 | + <Order>1</Order> |
| 34 | + <Path>reg add "HKLM\SYSTEM\Setup\LabConfig" /v BypassTPMCheck /t REG_DWORD /d 1 /f</Path> |
| 35 | + </RunSynchronousCommand> |
| 36 | + <RunSynchronousCommand wcm:action="add"> |
| 37 | + <Order>2</Order> |
| 38 | + <Path>reg add "HKLM\SYSTEM\Setup\LabConfig" /v BypassSecureBootCheck /t REG_DWORD /d 1 /f</Path> |
| 39 | + </RunSynchronousCommand> |
| 40 | + <RunSynchronousCommand wcm:action="add"> |
| 41 | + <Order>3</Order> |
| 42 | + <Path>reg add "HKLM\SYSTEM\Setup\LabConfig" /v BypassRAMCheck /t REG_DWORD /d 1 /f</Path> |
| 43 | + </RunSynchronousCommand> |
| 44 | + <RunSynchronousCommand wcm:action="add"> |
| 45 | + <Order>4</Order> |
| 46 | + <Path>reg add "HKLM\SYSTEM\Setup\LabConfig" /v BypassCPUCheck /t REG_DWORD /d 1 /f</Path> |
| 47 | + </RunSynchronousCommand> |
| 48 | + <RunSynchronousCommand wcm:action="add"> |
| 49 | + <Order>5</Order> |
| 50 | + <Path>reg add "HKLM\SYSTEM\Setup\LabConfig" /v BypassStorageCheck /t REG_DWORD /d 1 /f</Path> |
| 51 | + </RunSynchronousCommand> |
| 52 | + <RunSynchronousCommand wcm:action="add"> |
| 53 | + <Order>6</Order> |
| 54 | + <Path>reg add "HKLM\SYSTEM\Setup\MoSetup" /v AllowUpgradesWithUnsupportedTPMOrCPU /t REG_DWORD /d 1 /f</Path> |
| 55 | + </RunSynchronousCommand> |
| 56 | + </RunSynchronous> |
| 57 | + |
| 58 | + <UserData> |
| 59 | + <AcceptEula>true</AcceptEula> |
| 60 | + <FullName>User</FullName> |
| 61 | + <Organization>Lima</Organization> |
| 62 | + <ProductKey> |
| 63 | + <WillShowUI>Never</WillShowUI> |
| 64 | + </ProductKey> |
| 65 | + </UserData> |
| 66 | + |
| 67 | + <!-- GPT partition layout for UEFI boot. |
| 68 | + NOTE: On amd64, disk is attached via SATA/AHCI so WinPE can see it without extra drivers. --> |
| 69 | + <DiskConfiguration> |
| 70 | + <Disk wcm:action="add"> |
| 71 | + <DiskID>0</DiskID> |
| 72 | + <WillWipeDisk>true</WillWipeDisk> |
| 73 | + <CreatePartitions> |
| 74 | + <CreatePartition wcm:action="add"> |
| 75 | + <Order>1</Order> |
| 76 | + <Type>EFI</Type> |
| 77 | + <Size>100</Size> |
| 78 | + </CreatePartition> |
| 79 | + <CreatePartition wcm:action="add"> |
| 80 | + <Order>2</Order> |
| 81 | + <Type>MSR</Type> |
| 82 | + <Size>16</Size> |
| 83 | + </CreatePartition> |
| 84 | + <CreatePartition wcm:action="add"> |
| 85 | + <Order>3</Order> |
| 86 | + <Type>Primary</Type> |
| 87 | + <Extend>true</Extend> |
| 88 | + </CreatePartition> |
| 89 | + </CreatePartitions> |
| 90 | + <ModifyPartitions> |
| 91 | + <ModifyPartition wcm:action="add"> |
| 92 | + <Order>1</Order> |
| 93 | + <PartitionID>1</PartitionID> |
| 94 | + <Label>System</Label> |
| 95 | + <Format>FAT32</Format> |
| 96 | + </ModifyPartition> |
| 97 | + <ModifyPartition wcm:action="add"> |
| 98 | + <Order>2</Order> |
| 99 | + <PartitionID>2</PartitionID> |
| 100 | + </ModifyPartition> |
| 101 | + <ModifyPartition wcm:action="add"> |
| 102 | + <Order>3</Order> |
| 103 | + <PartitionID>3</PartitionID> |
| 104 | + <Label>Windows</Label> |
| 105 | + <Format>NTFS</Format> |
| 106 | + <Letter>C</Letter> |
| 107 | + </ModifyPartition> |
| 108 | + </ModifyPartitions> |
| 109 | + </Disk> |
| 110 | + </DiskConfiguration> |
| 111 | + |
| 112 | + <!-- Index 6 = Pro on Win10/Win11 x86_64 multi-edition ISOs --> |
| 113 | + <ImageInstall> |
| 114 | + <OSImage> |
| 115 | + <InstallTo> |
| 116 | + <DiskID>0</DiskID> |
| 117 | + <PartitionID>3</PartitionID> |
| 118 | + </InstallTo> |
| 119 | + <InstallToAvailablePartition>false</InstallToAvailablePartition> |
| 120 | + <OSImageIndex>6</OSImageIndex> |
| 121 | + </OSImage> |
| 122 | + </ImageInstall> |
| 123 | + |
| 124 | + </component> |
| 125 | + </settings> |
| 126 | + |
| 127 | + <!-- specialize: machine identity (runs after file copy, before first boot) --> |
| 128 | + <settings pass="specialize"> |
| 129 | + <component name="Microsoft-Windows-Shell-Setup" |
| 130 | + processorArchitecture="amd64" |
| 131 | + publicKeyToken="31bf3856ad364e35" |
| 132 | + language="neutral" |
| 133 | + versionScope="nonSxS" |
| 134 | + xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State"> |
| 135 | + <ComputerName>lima-default</ComputerName> |
| 136 | + <TimeZone>UTC</TimeZone> |
| 137 | + </component> |
| 138 | + </settings> |
| 139 | + |
| 140 | + <!-- oobeSystem: suppress OOBE prompts, create user, install OpenSSH --> |
| 141 | + <settings pass="oobeSystem"> |
| 142 | + <component name="Microsoft-Windows-Shell-Setup" |
| 143 | + processorArchitecture="amd64" |
| 144 | + publicKeyToken="31bf3856ad364e35" |
| 145 | + language="neutral" |
| 146 | + versionScope="nonSxS" |
| 147 | + xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State"> |
| 148 | + <OOBE> |
| 149 | + <HideEULAPage>true</HideEULAPage> |
| 150 | + <HideLocalAccountScreen>false</HideLocalAccountScreen> |
| 151 | + <HideOnlineAccountScreens>true</HideOnlineAccountScreens> |
| 152 | + <HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE> |
| 153 | + <NetworkLocation>Work</NetworkLocation> |
| 154 | + <ProtectYourPC>3</ProtectYourPC> |
| 155 | + <SkipMachineOOBE>true</SkipMachineOOBE> |
| 156 | + <SkipUserOOBE>true</SkipUserOOBE> |
| 157 | + </OOBE> |
| 158 | + <UserAccounts> |
| 159 | + <LocalAccounts> |
| 160 | + <LocalAccount wcm:action="add"> |
| 161 | + <Name>lima</Name> |
| 162 | + <DisplayName>lima</DisplayName> |
| 163 | + <Group>Administrators</Group> |
| 164 | + <Password> |
| 165 | + <Value></Value> |
| 166 | + <PlainText>true</PlainText> |
| 167 | + </Password> |
| 168 | + </LocalAccount> |
| 169 | + </LocalAccounts> |
| 170 | + </UserAccounts> |
| 171 | + <AutoLogon> |
| 172 | + <Enabled>true</Enabled> |
| 173 | + <Username>lima</Username> |
| 174 | + <Password> |
| 175 | + <Value></Value> |
| 176 | + <PlainText>true</PlainText> |
| 177 | + </Password> |
| 178 | + <LogonCount>3</LogonCount> |
| 179 | + </AutoLogon> |
| 180 | + |
| 181 | + <!-- Install and configure OpenSSH server for Lima host-agent connectivity --> |
| 182 | + <FirstLogonCommands> |
| 183 | + <SynchronousCommand wcm:action="add"> |
| 184 | + <Order>1</Order> |
| 185 | + <CommandLine>powershell.exe -NoProfile -Command "Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0"</CommandLine> |
| 186 | + <Description>Install OpenSSH Server</Description> |
| 187 | + </SynchronousCommand> |
| 188 | + <SynchronousCommand wcm:action="add"> |
| 189 | + <Order>2</Order> |
| 190 | + <CommandLine>powershell.exe -NoProfile -Command "Start-Service sshd; Set-Service -Name sshd -StartupType Automatic"</CommandLine> |
| 191 | + <Description>Start and enable sshd</Description> |
| 192 | + </SynchronousCommand> |
| 193 | + <SynchronousCommand wcm:action="add"> |
| 194 | + <Order>3</Order> |
| 195 | + <CommandLine>powershell.exe -NoProfile -Command "New-Item -Path 'C:\ProgramData\ssh' -ItemType Directory -Force"</CommandLine> |
| 196 | + <Description>Create SSH config directory</Description> |
| 197 | + </SynchronousCommand> |
| 198 | + <SynchronousCommand wcm:action="add"> |
| 199 | + <Order>4</Order> |
| 200 | + <CommandLine>powershell.exe -NoProfile -Command "Set-Content -Path 'C:\ProgramData\ssh\administrators_authorized_keys' -Value 'ssh-rsa PLACEHOLDER'; icacls 'C:\ProgramData\ssh\administrators_authorized_keys' /inheritance:r /grant 'SYSTEM:(F)' /grant 'Administrators:(F)'"</CommandLine> |
| 201 | + <Description>Write authorized_keys with correct ACLs</Description> |
| 202 | + </SynchronousCommand> |
| 203 | + <SynchronousCommand wcm:action="add"> |
| 204 | + <Order>5</Order> |
| 205 | + <CommandLine>powershell.exe -NoProfile -Command "$cfg = 'C:\ProgramData\ssh\sshd_config'; (Get-Content $cfg) -replace '#?AuthorizedKeysFile.*', 'AuthorizedKeysFile .ssh/authorized_keys' | Set-Content $cfg; Add-Content $cfg 'Match Group administrators`r`n AuthorizedKeysFile C:/ProgramData/ssh/administrators_authorized_keys'; Restart-Service sshd"</CommandLine> |
| 206 | + <Description>Configure sshd for admin key auth</Description> |
| 207 | + </SynchronousCommand> |
| 208 | + <SynchronousCommand wcm:action="add"> |
| 209 | + <Order>6</Order> |
| 210 | + <CommandLine>reg.exe add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v AutoAdminLogon /t REG_SZ /d 0 /f</CommandLine> |
| 211 | + <Description>Disable auto-logon after provisioning</Description> |
| 212 | + </SynchronousCommand> |
| 213 | + <SynchronousCommand wcm:action="add"> |
| 214 | + <Order>7</Order> |
| 215 | + <CommandLine>powershell.exe -NoProfile -Command "New-NetFirewallRule -Name 'OpenSSH-Server' -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22"</CommandLine> |
| 216 | + <Description>Allow SSH through firewall</Description> |
| 217 | + </SynchronousCommand> |
| 218 | + </FirstLogonCommands> |
| 219 | + </component> |
| 220 | + <component name="Microsoft-Windows-International-Core" |
| 221 | + processorArchitecture="amd64" |
| 222 | + publicKeyToken="31bf3856ad364e35" |
| 223 | + language="neutral" |
| 224 | + versionScope="nonSxS" |
| 225 | + xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State"> |
| 226 | + <InputLocale>en-US</InputLocale> |
| 227 | + <SystemLocale>en-US</SystemLocale> |
| 228 | + <UILanguage>en-US</UILanguage> |
| 229 | + <UserLocale>en-US</UserLocale> |
| 230 | + </component> |
| 231 | + </settings> |
| 232 | + |
| 233 | +</unattend> |
0 commit comments