Skip to content

Commit d6332ba

Browse files
hhfrancoisclaude
andcommitted
fix(agent): Windows installer download uses a throwaway known_hosts, not NUL
The internal plug.exe download also passed UserKnownHostsFile=NUL. From Git Bash that NUL is a literal file (not the null device), so a recreated agent's changed host key clashed with a stale one and the download failed. Use a unique temp known_hosts file per run — a real path both native and MSYS/Git ssh honour — removed afterwards. No clash, no shell dependency. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent fabeaab commit d6332ba

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

agent/install.ps1

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,19 @@ function Get-AgentBinary($outFile) {
101101
# to the file (no newline mangling) and is Windows-PowerShell-5.1 compatible
102102
# (ProcessStartInfo.ArgumentList is not). stderr goes to a temp file.
103103
$errFile = Join-Path ([System.IO.Path]::GetTempPath()) ("plug-ssh-" + [guid]::NewGuid().ToString('N') + '.err')
104+
# A throwaway known_hosts FILE (a real path, not the NUL device): interpreted the
105+
# same by native and MSYS/Git ssh, and unique per run, so a recreated agent's new
106+
# host key never clashes with a stale one (StrictHostKeyChecking=no records it).
107+
$khFile = Join-Path ([System.IO.Path]::GetTempPath()) ("plug-kh-" + [guid]::NewGuid().ToString('N'))
104108
$sshArgs = @('-p', $SshPort,
105109
'-o', 'StrictHostKeyChecking=no',
106-
'-o', 'UserKnownHostsFile=NUL',
110+
'-o', "UserKnownHostsFile=$khFile",
107111
'-o', 'LogLevel=ERROR',
108112
'-o', 'BatchMode=yes',
109113
"get@$SshHost", 'windows-amd64')
110114
$p = Start-Process -FilePath 'ssh' -ArgumentList $sshArgs -NoNewWindow -Wait -PassThru `
111115
-RedirectStandardOutput $outFile -RedirectStandardError $errFile
116+
Remove-Item -LiteralPath $khFile -ErrorAction SilentlyContinue
112117
$stderr = ''
113118
if (Test-Path -LiteralPath $errFile) {
114119
$stderr = (Get-Content -LiteralPath $errFile -Raw -ErrorAction SilentlyContinue)

0 commit comments

Comments
 (0)