From 70a727782125455596a7a317c65a882fd38d3758 Mon Sep 17 00:00:00 2001 From: Tess Gauthier Date: Mon, 7 Jul 2025 14:09:41 -0400 Subject: [PATCH 1/2] fix logic for empty property --- contrib/win32/openssh/FixHostFilePermissions.ps1 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/contrib/win32/openssh/FixHostFilePermissions.ps1 b/contrib/win32/openssh/FixHostFilePermissions.ps1 index c990a0d0126..11c95fe7cf6 100644 --- a/contrib/win32/openssh/FixHostFilePermissions.ps1 +++ b/contrib/win32/openssh/FixHostFilePermissions.ps1 @@ -48,11 +48,11 @@ Get-ChildItem "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList" if($properties) { $userProfilePath = $properties.ProfileImagePath - } - $filePath = Join-Path $userProfilePath .ssh\authorized_keys - if(Test-Path $filePath -PathType Leaf) - { - Repair-AuthorizedKeyPermission -FilePath $filePath @psBoundParameters + $filePath = Join-Path $userProfilePath .ssh\authorized_keys + if(Test-Path $filePath -PathType Leaf) + { + Repair-AuthorizedKeyPermission -FilePath $filePath @psBoundParameters + } } } From a95b634ccf0fb63e1de88d28c09c7076ca2d303d Mon Sep 17 00:00:00 2001 From: Tess Gauthier Date: Mon, 7 Jul 2025 14:21:34 -0400 Subject: [PATCH 2/2] Update contrib/win32/openssh/FixHostFilePermissions.ps1 Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- contrib/win32/openssh/FixHostFilePermissions.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/win32/openssh/FixHostFilePermissions.ps1 b/contrib/win32/openssh/FixHostFilePermissions.ps1 index 11c95fe7cf6..1318e7b9eca 100644 --- a/contrib/win32/openssh/FixHostFilePermissions.ps1 +++ b/contrib/win32/openssh/FixHostFilePermissions.ps1 @@ -45,7 +45,7 @@ Get-ChildItem $env:ProgramData\ssh\ssh_host_*_key -ErrorAction SilentlyContinue Get-ChildItem "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList" -ErrorAction SilentlyContinue | % { $properties = Get-ItemProperty $_.pspath -ErrorAction SilentlyContinue $userProfilePath = "" - if($properties) + if($properties -and $properties.ProfileImagePath) { $userProfilePath = $properties.ProfileImagePath $filePath = Join-Path $userProfilePath .ssh\authorized_keys