-
Notifications
You must be signed in to change notification settings - Fork 251
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding Winrm https support #24
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ if(Test-PendingReboot){ Invoke-Reboot } | |
|
||
Write-BoxstarterMessage "Setting up winrm" | ||
netsh advfirewall firewall add rule name="WinRM-HTTP" dir=in localport=5985 protocol=TCP action=allow | ||
netsh advfirewall firewall add rule name="WinRM-HTTPS" dir=in localport=5986 protocol=TCP action=allow | ||
|
||
$enableArgs=@{Force=$true} | ||
try { | ||
|
@@ -42,4 +43,27 @@ Enable-WSManCredSSP -Force -Role Server | |
winrm set winrm/config/client/auth '@{Basic="true"}' | ||
winrm set winrm/config/service/auth '@{Basic="true"}' | ||
winrm set winrm/config/service '@{AllowUnencrypted="true"}' | ||
Write-BoxstarterMessage "winrm setup complete" | ||
winrm set winrm/config/winrs '@{MaxMemoryPerShellMB="300"}' | ||
winrm set winrm/config '@{MaxTimeoutms="1800000"}' | ||
|
||
Write-BoxstarterMessage "Reusing RDP self-signed certificate for WinRM HTTPS" | ||
$SourceStoreScope = 'LocalMachine' | ||
$SourceStorename = 'Remote Desktop' | ||
$SourceStore = New-Object -TypeName System.Security.Cryptography.X509Certificates.X509Store -ArgumentList $SourceStorename, $SourceStoreScope | ||
$SourceStore.Open([System.Security.Cryptography.X509Certificates.OpenFlags]::ReadOnly) | ||
$cert = $SourceStore.Certificates | Where-Object -FilterScript { | ||
$_.subject -like '*' | ||
} | ||
|
||
$DestStoreScope = 'LocalMachine' | ||
$DestStoreName = 'My' | ||
$DestStore = New-Object -TypeName System.Security.Cryptography.X509Certificates.X509Store -ArgumentList $DestStoreName, $DestStoreScope | ||
$DestStore.Open([System.Security.Cryptography.X509Certificates.OpenFlags]::ReadWrite) | ||
$DestStore.Add($cert) | ||
|
||
$SourceStore.Close() | ||
$DestStore.Close() | ||
|
||
winrm create winrm/config/listener?Address=*+Transport=HTTPS `@`{Hostname=`"($certId)`"`;CertificateThumbprint=`"($cert.Thumbprint)`"`} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is cool. You'd probably also have to enable 5986 on the firewall too for this to work right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, added above at line 29 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be better to put this added block BEFORE lines 43-45. The reason is that as soon as those lines succeed, packer is able to successfully connect and will start the shutdown process. There's a good chance it will still succeed since the shutdown process includes a sysprep and so there is still a small amount of time for the remaining code to complete, but its just safer to always have those three lines at the very end. |
||
Write-BoxstarterMessage "winrm setup complete" |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
"type": "virtualbox-iso", | ||
"vboxmanage": [ | ||
[ "modifyvm", "{{.Name}}", "--natpf1", "guest_winrm,tcp,,55985,,5985" ], | ||
[ "modifyvm", "{{.Name}}", "--natpf1", "guest_winrm_ssl,tcp,,55986,,5986" ], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like a duplicate forwarding? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a second forwarding for https, so we can test both with same image. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah right. I must be getting old. |
||
[ "modifyvm", "{{.Name}}", "--memory", "2048" ], | ||
[ "modifyvm", "{{.Name}}", "--vram", "36" ], | ||
[ "modifyvm", "{{.Name}}", "--cpus", "2" ] | ||
|
@@ -29,14 +30,15 @@ | |
"scripts/PackerShutdown.bat", | ||
"scripts/package.ps1", | ||
"scripts/SetupComplete-2012.cmd", | ||
"scripts/test-command.ps1" | ||
"scripts/Test-Command.ps1" | ||
] | ||
}, | ||
{ | ||
"name": "virtualbox-iso-atlas", | ||
"type": "virtualbox-iso", | ||
"vboxmanage": [ | ||
[ "modifyvm", "{{.Name}}", "--natpf1", "guest_winrm,tcp,,55985,,5985" ], | ||
[ "modifyvm", "{{.Name}}", "--natpf1", "guest_winrm_ssl,tcp,,55986,,5986" ], | ||
[ "modifyvm", "{{.Name}}", "--memory", "2048" ], | ||
[ "modifyvm", "{{.Name}}", "--vram", "36" ], | ||
[ "modifyvm", "{{.Name}}", "--cpus", "2" ] | ||
|
@@ -60,7 +62,7 @@ | |
"scripts/PackerShutdown.bat", | ||
"scripts/package.ps1", | ||
"scripts/SetupComplete-2012.cmd", | ||
"scripts/test-command.ps1" | ||
"scripts/Test-Command.ps1" | ||
] | ||
} | ||
], | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Windows Firewall change adding 5986