Skip to content

Commit a87bc1d

Browse files
committed
OpenSSH: install as part of VM setup, not WinRM
It appears that executing `Add-WindowsCapability` via WinRM is not viable, this commit moves the installation of OpenSSH.Server to the various IaaS pre-boot scrips which are not executed via WinRM.
1 parent 311be56 commit a87bc1d

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

lib/packer/config/azure.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ def builders
4545
'winrm_use_ssl' => 'true',
4646
'winrm_insecure' => 'true',
4747
'winrm_timeout' => '1h',
48-
'winrm_username' => 'packer'
48+
'winrm_username' => 'packer',
49+
'custom_script' => 'powershell -ExecutionPolicy Unrestricted -NoProfile -NonInteractive -Command "Add-WindowsCapability -Online -Name (Get-WindowsCapability -Online -Name OpenSSH.Server* | ForEach-Object Name)"'
4950
}
5051
]
5152
end

scripts/aws/setup_winrm.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,10 @@ if (-not (Get-Command Enable-WinRM -errorAction SilentlyContinue))
3434
Write-Log "Invoking WinRM"
3535
Enable-WinRM
3636

37+
Write-Log "Install OpenSSH.Server"
38+
Write-Log (Get-WindowsCapability -Online -Name "OpenSSH.Server*" | Format-List | Out-String)
39+
Add-WindowsCapability -Online -Name (Get-WindowsCapability -Online -Name "OpenSSH.Server*" | ForEach-Object Name)
40+
Write-Log (Get-WindowsCapability -Online -Name "OpenSSH.Server*" | Format-List | Out-String)
41+
3742
Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope LocalMachine
3843
</powershell>

scripts/gcp/setup-winrm.ps1

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,8 @@ if (-not (Get-Command Enable-WinRM -errorAction SilentlyContinue))
3232

3333
Write-Log "Invoking WinRM"
3434
Enable-WinRM
35+
36+
Write-Log "Install OpenSSH.Server"
37+
Write-Log (Get-WindowsCapability -Online -Name "OpenSSH.Server*" | Format-List | Out-String)
38+
Add-WindowsCapability -Online -Name (Get-WindowsCapability -Online -Name "OpenSSH.Server*" | ForEach-Object Name)
39+
Write-Log (Get-WindowsCapability -Online -Name "OpenSSH.Server*" | Format-List | Out-String)

0 commit comments

Comments
 (0)