openssh-portable
openssh-portable copied to clipboard
Use backslash for path displayed on Windows
PR Summary
Currently, ssh-keygen outputs the following, where the mixed slashes cause confusion
$ ssh-keygen
Generating public/private ed25519 key pair.
Enter file in which to save the key (C:\Users\aanand/.ssh/id_ed25519):
$ ssh-keygen -y
Enter file in which the key is (C:\Users\aanand/.ssh/id_ed25519):
$ ssh-add
Enter passphrase for C:\Users\aanand/.ssh/id_ed25519:
This pull request uses a _PATH_SEPARATOR macro to separate path elements with \ on Windows, and a / on other platforms. The new output is
$ ssh-keygen
Generating public/private ed25519 key pair.
Enter file in which to save the key (C:\Users\aanand\.ssh\id_ed25519):
$ ssh-keygen -y
Enter file in which the key is (C:\Users\aanand\.ssh\id_ed25519):
$ ssh-add
Enter passphrase for C:\Users\aanand\.ssh\id_ed25519:
to align with what a Windows user would expect to see.
PR Context
The confusion this issue causes is described in issues like this one.
@microsoft-github-policy-service agree
I have attempted to be conservative about this adjustment and aimed to correct the paths used in the client, and not in the server.
I have not rigorously tested these changes. Guidance about what scenarios need to be tested would be appreciated.
/AzurePipelines run
Azure Pipelines successfully started running 1 pipeline(s).
@akainth015 - looks like these changes break the CI during the E2E test setup, can you look into that? At a quick glance, it's not clear to me if it's an actual issue or if the test setup just needs updating to work with the changes.
Info on running the tests is at https://github.com/PowerShell/Win32-OpenSSH/wiki/Run-OpenSSH-Pester-Tests
Are there more up-to-date instructions? The commands related to testing, on the wiki page related to testing error as follows.
Import-Module: The specified module 'OpenSSHUtils' was not loaded because no valid module file was found in any module directory.
Based upon this unexpected log message, something is going awry near this line. Once I can find a way to run the tests locally then I would be able to look into it further.
Are there more up-to-date instructions? The commands related to testing, on the wiki page related to testing error as follows.
Import-Module: The specified module 'OpenSSHUtils' was not loaded because no valid module file was found in any module directory.
The OpenSSHUtils module is located in the bin with OpenSSH binaries or in the repo under /contrib/win32/openssh - https://github.com/PowerShell/openssh-portable/blob/latestw_all/contrib/win32/openssh/OpenSSHUtils.psm1
Please run Import-Module <path to OpenSSHUtils> then try the commands again.
No dice. I have also tried running the pester tests directly and running from within the .\bin\x64\Debug and .\contrib\win32\openssh directories. All fail with the same error.
~
❯ cd D:\openssh-portable\
openssh-portable on latestw_all [!] via C
❯ Import-Module .\contrib\win32\openssh\OpenSSHUtils.psm1
openssh-portable on latestw_all [!] via C
❯ Import-Module .\contrib\win32\openssh\OpenSSHBuildHelper.psm1 -Force
openssh-portable on latestw_all [!] via C
❯ Start-OpenSSHBuild -Configuration Debug -NativeHostArch x64
C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath
C:\Program Files\Microsoft Visual Studio\2022\Community
C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath
Using MSBuild path: C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\amd64\MSBuild.exe
Starting Open SSH build; Build Log: D:\openssh-portable\contrib\win32\openssh\OpenSSHDebugx64.log.
C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\amd64\MSBuild.exe D:\openssh-portable\contrib\win32\openssh\Win32-OpenSSH.sln /t:Rebuild /p:Platform=x64 /p:Configuration=Debug /m /nologo /fl /flp:LogFile=D:\openssh-portable\contrib\win32\openssh\OpenSSHDebugx64.log;Append;Verbosity=diagnostic /noconlog
SSH build successful.
openssh-portable on latestw_all [!] via C took 29s
❯ Import-Module .\contrib\win32\openssh\OpenSSHTestHelper.psm1 -Force
openssh-portable on latestw_all [!] via C
❯ Set-OpenSSHTestEnvironment -Confirm:$false -OpenSSHBinPath .\bin\x64\Debug\
VERBOSE: Installing Module OpenSSHUtils...
Import-Module: The specified module 'OpensshUtils' was not loaded because no valid module file was found in any module directory.
hmm, are you using Windows PowerShell (5.1) or PowerShell core (7.4)?
Can you try the following, based on https://github.com/PowerShell/openssh-portable/blob/latestw_all/.azdo/ci.yml#L198: Import-Module -Name "D:\openssh-portable\contrib\win32\openssh\AzDOBuildTools" -Force Invoke-OpenSSHTests -OpenSSHBinPath "D:\openssh-portable\bin\x64\debug"
I am using PowerShell 7.4.1. The Import-Module succeeded, but it did not help with getting the tests to run. The error message did not change.
I have also tried in Windows PowerShell 5.1. Here are the results of that.
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
Install the latest PowerShell for new features and improvements! https://aka.ms/PSWindows
PS C:\Users\aanand> cd D:\openssh-portable\
PS D:\openssh-portable> Import-Module -Name "D:\openssh-portable\contrib\win32\openssh\AzDOBuildTools" -Force
PS D:\openssh-portable> Import-Module .\contrib\win32\openssh\OpenSSHTestHelper.psm1 -Force
PS D:\openssh-portable> Set-OpenSSHTestEnvironment -Confirm:$false -OpenSSHBinPath .\bin\x64\Debug\
VERBOSE: Installing Module OpenSSHUtils...
Copy-item : Could not find a part of the path 'C:\Program Files\WindowsPowerShell\Modules\OpenSSHUtils\1.0.0.1'.
At D:\openssh-portable\contrib\win32\openssh\OpenSSHTestHelper.psm1:465 char:5
+ Copy-item "$manifestFile" -Destination "$targetDirectory" -Force ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Copy-Item], DirectoryNotFoundException
+ FullyQualifiedErrorId : System.IO.DirectoryNotFoundException,Microsoft.PowerShell.Commands.CopyItemCommand
PS D:\openssh-portable> Import-Module .\contrib\win32\openssh\OpenSSHUtils.psm1
PS D:\openssh-portable> Set-OpenSSHTestEnvironment -Confirm:$false -OpenSSHBinPath .\bin\x64\Debug\
VERBOSE: Installing Module OpenSSHUtils...
Copy-item : Could not find a part of the path 'C:\Program Files\WindowsPowerShell\Modules\OpenSSHUtils\1.0.0.1'.
At D:\openssh-portable\contrib\win32\openssh\OpenSSHTestHelper.psm1:465 char:5
+ Copy-item "$manifestFile" -Destination "$targetDirectory" -Force ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Copy-Item], DirectoryNotFoundException
+ FullyQualifiedErrorId : System.IO.DirectoryNotFoundException,Microsoft.PowerShell.Commands.CopyItemCommand
PS D:\openssh-portable> echo $PSVersionTable
Name Value
---- -----
PSVersion 5.1.22621.2506
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.22621.2506
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Can you try manually copying both OpenSSHUtils.psm1 and OpenSSHUtils.psd1 to C:\Program Files\WindowsPowerShell\Modules\OpenSSHUtils\1.0.0.1 and rerunning in Windows PowerShell?