vmware-samples / packer-examples-for-vsphere

Packer Examples for vSphere
https://vmware-samples.github.io/packer-examples-for-vsphere/
Other
829 stars 326 forks source link

Add option to use SSH communicator for Windows #715

Closed tintinhamans closed 7 months ago

tintinhamans commented 1 year ago

Code of Conduct

Description

Since Windows Server 2019/Windows 10 (build 1809), OpenSSH server has been available as a Windows feature. Packer supports using the SSH communicator for Windows so it would be nice if that option was made available.

Use Case(s)

Potential Configuration

Introduce communicator_windows variable which can be set to either "winrm" or "ssh".

Modify autounattend.xml to use different init script depending on communicator_windows.

Example SSH config in init script:

# Install OpenSSH
Write-Output 'Installing the OpenSSH client...'
Add-WindowsCapability -Online -Name 'OpenSSH.Client~~~~0.0.1.0'

Write-Output 'Installing the OpenSSH server...'
Add-WindowsCapability -Online -Name 'OpenSSH.Server~~~~0.0.1.0'

# Configure OpenSSH server
Write-Output 'Starting OpenSSH server...'
Start-Service sshd

Write-Output 'Setting OpenSSH server to start automatically...'
Set-Service -Name sshd -StartupType 'Automatic'

# Allow OpenSSH Server in the Windows Firewall
Write-Output 'Allowing OpenSSH server in the Windows Firewall...'
netsh advfirewall firewall set rule group="OpenSSH Server" new enable=yes
netsh advfirewall firewall set rule name="OpenSSH SSH Server (sshd)" new enable=yes action=allow

References

github-actions[bot] commented 11 months ago

Marking this issue as stale due to inactivity. This helps us focus on the active issues. If this issue receives no comments in the next 30 days it will automatically be closed.

If this issue was automatically closed and you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thank you!

github-actions[bot] commented 8 months ago

Marking this issue as stale due to inactivity. This helps us focus on the active issues. If this issue receives no comments in the next 30 days it will automatically be closed.

If this issue was automatically closed and you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thank you!