Skip to content

SSH KeyFilePath parameter not working  #4475

@luzlab

Description

@luzlab

When I try running New-PSSession or Enter-PSSession using a public key, powershell either:

  1. When passed a valid KeyFilePath, complains that it doesn't exist and continues gracefully to password-based authentication.
  2. When passed a bogus KeyFilePath, throws an ItemNotFoundException

Steps to reproduce

> New-PSSession -UserName "xx" -KeyFilePath "/fakepath" -Hostname " xx.xx.xx.xx"
New-PSSession : Cannot find path 'doesntexist' because it does not exist.
At line:1 char:1
+ New-PSSession -UserName "Administrator" -KeyFilePath "doesntexist" -H ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (doesntexist:String) [New-PSSession], ItemNotFoundException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.NewPSSessionCommand

> New-PSSession -UserName "xx" -KeyFilePath "~/.ssh/id_rsa" -Hostname " xx.xx.xx.xx"
Warning: Identity file "/Users/cquinonez/.ssh/workgangkey" not accessible: No such file or directory.

Expected behavior

>  New-PSSession -UserName "xx" -KeyFilePath "/fakepath" -Hostname " xx.xx.xx.xx"
Warning: Identity file "/Users/cquinonez/.ssh/workgangkey" not accessible: No such file or directory.
>  New-PSSession -UserName "xx" -KeyFilePath "<validKeyFilePath>" -Hostname " xx.xx.xx.xx"

 Id Name            ComputerName    ComputerType    State         ConfigurationName     Availability
 -- ----            ------------    ------------    -----         -----------------     ------------
  1 SSH1            xx.xx.xx.xx     RemoteMachine   Opened        DefaultShell             Available

Actual behavior

untitled

I've verified that Test-Path also correctly detects the key file as well.

Environment data

> $PSVersionTable
Name                           Value
----                           -----
PSVersion                      6.0.0-beta
PSEdition                      Core
GitCommitId                    v6.0.0-beta.4
OS                             Darwin 16.7.0 Darwin Kernel Version 16.7.0: Thu Jun 15 17:36:27 PDT 2017; root:xnu-3789.70.16~2/RELEASE_X86_64
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Metadata

Metadata

Assignees

Labels

Issue-BugIssue has been identified as a bug in the productResolution-FixedThe issue is fixed.Size-DaysWG-RemotingPSRP issues with any transport layer

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions