Transport error when allowing a new host during SSH PowerShell remoting #2432

Closed
PaulHigin opened this Issue Oct 6, 2016 · 6 comments

Comments

Projects
None yet
4 participants
@PaulHigin
Contributor

PaulHigin commented Oct 6, 2016

This seems to be a bug only in Win32-OpenSSH ssh.exe client, so I'll create an issue there as well. When the client prompts for host authenticity ssh.exe writes an error in StdErr with a blank message string. Currently PowerShell SSH remoting treats any StdErr from ssh.exe client as a terminating error and terminates the transport connection. This does not repro on a Linux client but only on Windows using Win32-OpenSSH.

The fix in PowerShell SSH remoting is to ignore all blank error messages from StdErr.

Steps to reproduce

PS C:\> del C:\users\<user>\.ssh\known_hosts
PS C:\> New-PSSession -HostName $env:computername -UserName userName
The authenticity of host 'computer' can't be established.
ECDSA key fingerprint is SHA256:AeRUkqd3vJjZDNI07Do4BBpmutic4UR35bKw3FBV6a4.
Are you sure you want to continue connecting (yes/no)?
Warning: Permanently added 'computer' to the list of known hosts.

New-PSSession : [computer] The background process reported an error with the following message: The SSH client session has
ended with no error message..
At line:1 char:1
+ New-PSSession -HostName $env:computername -user userName
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) [New-PSSession], PSRemotin
   gTransportException
    + FullyQualifiedErrorId : 2100,PSSessionOpenFailed

Expected behavior

No error after adding target computer to trusted hosts list.

Actual behavior

Error and connection termination.

@PaulHigin PaulHigin self-assigned this Oct 6, 2016

@PaulHigin PaulHigin added the Issue-Bug label Oct 6, 2016

@SteveL-MSFT SteveL-MSFT added this to the 6.0.0 milestone Oct 6, 2016

@energizedtech

This comment has been minimized.

Show comment
Hide comment
@energizedtech

energizedtech Oct 13, 2016

Running Server 2016 RTM / Ubuntu 16.0 server. Encountering the exact error when trying to initiate from Linux to Windows
$s=New-Pssession Hostname EotSrv2016 -username administrator

Running Server 2016 RTM / Ubuntu 16.0 server. Encountering the exact error when trying to initiate from Linux to Windows
$s=New-Pssession Hostname EotSrv2016 -username administrator

@energizedtech

This comment has been minimized.

Show comment
Hide comment
@energizedtech

energizedtech Oct 13, 2016

Can you supply the change to allow PSH remoting to ignore ?

Can you supply the change to allow PSH remoting to ignore ?

@PaulHigin

This comment has been minimized.

Show comment
Hide comment
@PaulHigin

PaulHigin Oct 13, 2016

Contributor

I have a simple fix for this but have not generated a PR yet. But this is not a blocking bug. I neglected to mention that the workaround is to simply run the New-PSSession Cmdlet a second time and the connection will succeed (since the host has been added to the trusted list).

If you are interested the fix is at https://github.com/PowerShell/PowerShell/blob/master/src/System.Management.Automation/engine/remoting/fanin/OutOfProcTransportManager.cs
line 1526 needs to change:

if (string.IsNullOrEmpty(error))
{
    // Ignore blank error messages.
    continue;
}
if (error.IndexOf("WARNING:", StringComparison.OrdinalIgnoreCase) > -1)
...
Contributor

PaulHigin commented Oct 13, 2016

I have a simple fix for this but have not generated a PR yet. But this is not a blocking bug. I neglected to mention that the workaround is to simply run the New-PSSession Cmdlet a second time and the connection will succeed (since the host has been added to the trusted list).

If you are interested the fix is at https://github.com/PowerShell/PowerShell/blob/master/src/System.Management.Automation/engine/remoting/fanin/OutOfProcTransportManager.cs
line 1526 needs to change:

if (string.IsNullOrEmpty(error))
{
    // Ignore blank error messages.
    continue;
}
if (error.IndexOf("WARNING:", StringComparison.OrdinalIgnoreCase) > -1)
...
@energizedtech

This comment has been minimized.

Show comment
Hide comment
@energizedtech

energizedtech Oct 13, 2016

For the PSRemoting, one piece to add to it's documentation would be a small section on "Validate the SSH works first" which helped me out :)

For the PSRemoting, one piece to add to it's documentation would be a small section on "Validate the SSH works first" which helped me out :)

@PaulHigin

This comment has been minimized.

Show comment
Hide comment
@PaulHigin

PaulHigin Oct 13, 2016

Contributor

Good point. Please feel free to update the document if you feel so inclined!

Contributor

PaulHigin commented Oct 13, 2016

Good point. Please feel free to update the document if you feel so inclined!

@PaulHigin

This comment has been minimized.

Show comment
Hide comment
@PaulHigin

PaulHigin Dec 7, 2016

Contributor

This issue has been fixed.

Contributor

PaulHigin commented Dec 7, 2016

This issue has been fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment