Skip to content

Commit 9307001

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. The installation of OpenSSSH.Server was added as follows: Azure: add a `custom_script` parameter to packer config AWS: added to `setup_winrm.txt` GCP: add to `setup-winrm.ps1` and use `sysprep-specialize-script-ps1` As of July 2025 windows stemcells have converted to using Microsoft's official OpenSSH installation method[1]. This commit remove the remnants of previous installation methods, and switches to the above non-WinRM method for installation. [1] https://learn.microsoft.com/en-us/windows-server/administration/openssh/openssh_install_firstuse
1 parent 7e6658e commit 9307001

File tree

19 files changed

+312
-510
lines changed

19 files changed

+312
-510
lines changed

ci/pipelines/stemcells-windows.yml

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -204,13 +204,6 @@ resources:
204204
password: ((docker.password))
205205

206206
# type: github-release
207-
- name: openssh-release
208-
type: github-release
209-
source:
210-
owner: PowerShell
211-
repository: Win32-OpenSSH
212-
access_token: ((github_public_repo_token))
213-
tag_filter: v([^v].*)
214207
- name: stemcell-builder-github-release
215208
type: github-release
216209
source:
@@ -793,8 +786,6 @@ jobs:
793786
tags: [*worker_tag]
794787
- get: bosh-windows-stemcell-builder-ci-image
795788
tags: [*worker_tag]
796-
- get: open-ssh
797-
resource: openssh-release
798789
- get: stemcell-builder
799790
passed: [build]
800791
tags: [*worker_tag]
@@ -912,8 +903,6 @@ jobs:
912903
tags: [*worker_tag]
913904
- get: bosh-windows-stemcell-builder-ci-image
914905
tags: [*worker_tag]
915-
- get: open-ssh
916-
resource: openssh-release
917906
- get: stemcell-builder
918907
passed: [build]
919908
tags: [*worker_tag]
@@ -1362,8 +1351,6 @@ jobs:
13621351
- get: main-version
13631352
passed: [build]
13641353
tags: [*worker_tag]
1365-
- get: sshd
1366-
resource: openssh-release
13671354
- get: bosh-agent-release
13681355
passed: [build]
13691356
- get: blobstore-dav-cli
@@ -1543,8 +1530,6 @@ jobs:
15431530
- get: main-version
15441531
passed: [wuts-aws]
15451532
tags: [*worker_tag]
1546-
- get: sshd
1547-
resource: openssh-release
15481533
- get: bosh-agent-release
15491534
passed: [wuts-aws]
15501535
- get: blobstore-dav-cli
@@ -1704,8 +1689,6 @@ jobs:
17041689
- get: main-version
17051690
passed: [build]
17061691
tags: [*worker_tag]
1707-
- get: sshd
1708-
resource: openssh-release
17091692
- get: bosh-agent-release
17101693
passed: [build]
17111694
- get: blobstore-dav-cli
@@ -1901,8 +1884,6 @@ jobs:
19011884
- get: main-version
19021885
passed: [build]
19031886
tags: [*worker_tag]
1904-
- get: sshd
1905-
resource: openssh-release
19061887
- get: bosh-agent-release
19071888
passed: [build]
19081889
- get: blobstore-dav-cli

ci/tasks/create-azure-stemcell/task.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ inputs:
66
- name: version
77
- name: stemcell-builder
88
- name: lgpo-binary
9-
- name: sshd
109
- name: bosh-agent-release
1110
- name: blobstore-dav-cli
1211
- name: blobstore-s3-cli

ci/tasks/create-gcp-stemcell/task.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ inputs:
77
- name: base-gcp-image
88
- name: version
99
- name: lgpo-binary
10-
- name: sshd
1110
- name: bosh-agent-release
1211
- name: blobstore-dav-cli
1312
- name: blobstore-s3-cli

ci/tasks/generate-deps-file/run.bash

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
#!/usr/bin/env bash
22
set -euo pipefail
33

4-
openssh_win64_sha256="$(shasum -a 256 open-ssh/OpenSSH-Win64.zip | cut -d " " -f 1)"
5-
openssh_win64_version="$(cat open-ssh/version)"
6-
74
psmodules_sha256="$(shasum -a 256 psmodules-zip-output/bosh-psmodules.zip | cut -d " " -f 1)"
85
psmodules_version="$(cat version/version)"
96

@@ -15,10 +12,6 @@ lgpo_version="3"
1512

1613
cat <<EOF > deps-file/deps.json
1714
{
18-
"OpenSSH-Win64.zip": {
19-
"sha": "${openssh_win64_sha256}",
20-
"version": "${openssh_win64_version}"
21-
},
2215
"bosh-psmodules.zip": {
2316
"sha": "${psmodules_sha256}",
2417
"version": "${psmodules_version}"

ci/tasks/generate-deps-file/task.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ platform: linux
44
inputs:
55
- name: bosh-windows-stemcell-builder-ci
66
- name: stemcell-builder
7-
- name: open-ssh
87
- name: lgpo-binary
98
- name: version
109
- name: bosh-agent

ci/tasks/zip-files/run.bash

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ ROOT_DIR=$(pwd)
66
REPO_ROOT="${REPO_ROOT:-"$(cd "$(dirname "${BASH_SOURCE[0]}")/../../.." && pwd)"}"
77
ZIP_FILE_DESTINATION="${ZIP_FILE_DESTINATION:-"${ROOT_DIR}/zip-file/StemcellAutomation-$(date +"%s").zip"}"
88

9-
OPENSSH_ZIP="${OPENSSH_ZIP:-"${ROOT_DIR}/open-ssh/OpenSSH-Win64.zip"}"
109
BOSH_PSMODULES_ZIP="${BOSH_PSMODULES_ZIP:-"${ROOT_DIR}/psmodules-zip-output/bosh-psmodules.zip"}"
1110
AGENT_ZIP="${AGENT_ZIP:-"${ROOT_DIR}/bosh-agent/agent.zip"}"
1211
DEPS_JSON="${DEPS_JSON:-"${ROOT_DIR}/deps-file/deps.json"}"
@@ -20,7 +19,7 @@ mkdir -p "${stemcell_automation_dir}"
2019

2120
declare -a files_to_zip
2221
mapfile -t files_to_zip < <(find "${REPO_ROOT}/stembuild/stemcell-automation" -type f -not -name "*Test*" -name "*.ps*1")
23-
files_to_zip+=("${OPENSSH_ZIP}" "${BOSH_PSMODULES_ZIP}" "${AGENT_ZIP}" "${DEPS_JSON}")
22+
files_to_zip+=("${BOSH_PSMODULES_ZIP}" "${AGENT_ZIP}" "${DEPS_JSON}")
2423

2524
cp "${files_to_zip[@]}" "${stemcell_automation_dir}"
2625

ci/tasks/zip-files/task.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ platform: linux
44
inputs:
55
- name: bosh-windows-stemcell-builder-ci
66
- name: stemcell-builder
7-
- name: open-ssh
87
- name: deps-file
98
- name: bosh-agent
109
- name: psmodules-zip-output

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

lib/packer/config/gcp.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ def initialize(
3939
end
4040

4141
def builders
42+
stemcell_builder_dir = File.expand_path('../../../../', __FILE__)
4243
[
4344
{
4445
'type' => 'googlecompute',
@@ -62,7 +63,7 @@ def builders
6263
'winrm_timeout' => '1h',
6364
'state_timeout' => '10m',
6465
'metadata' => {
65-
'sysprep-specialize-script-url' => 'https://raw.githubusercontent.com/cloudfoundry/bosh-windows-stemcell-builder/master/scripts/gcp/setup-winrm.ps1',
66+
'sysprep-specialize-script-ps1' => File.read(File.join(stemcell_builder_dir, 'scripts', 'gcp', 'setup-winrm.ps1')),
6667
'name' => "#{@vm_prefix}-#{Time.now.to_i}",
6768
}.compact_blank!
6869
}

lib/packer/config/templates/provision_windows2019.json.erb

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,6 @@
137137
"Protect-CFCell -IaaS <%= iaas %>"
138138
]
139139
},
140-
{
141-
"type": "file",
142-
"source": "../sshd/OpenSSH-Win64.zip",
143-
"destination": "C:\\provision\\OpenSSH-Win64.zip"
144-
},
145140
{
146141
"type": "powershell",
147142
"inline": [

0 commit comments

Comments
 (0)