Skip to content

PowerShell Core Enter-PSSession not exiting gracefully in Windows when connected to Linux. #4686

Closed

Description

I'm happy to say that I love connectivity in both directions 'Linux-to-Windows' and Windows-to-Linux' using OpenSSH-Win64. Now, in beta-6, I notice when exiting from Linux using Enter-PSSession in Windows, it doesn't exit gracefully. Meaning, that when typing 'Exit', its giving an error when it shouldn't.

Steps to reproduce

In Windows -> connect to Linux:
PS> Enter-PSSession -hostname orion -username maxt
:
[orion]: PS /home/maxt> exit
(gives error message and then disconnect)

Enter-PSSession -hostname orion -username maxt

Expected behavior

Typing 'exit' should terminate session without any errors

Actual behavior

Error message when exiting session.

PowerShell v6.0.0-beta.6
Copyright (C) Microsoft Corporation. All rights reserved.

WARNING: Appended Windows PowerShell PSModulePath
Loading personal and system profiles took 2520ms.
PS C:\Program Files\PowerShell\6.0.0-beta.6> enter-pssession -HostName orion -UserName maxt
maxt@orion's password:
[orion]: PS /home/maxt> exit
A task was canceled.
The SSH client session has ended with error message: A task was canceled.
    + CategoryInfo          : ResourceUnavailable: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : System.Management.Automation.Remoting.PSRemotingDataStructureException

PS C:\Program Files\PowerShell\6.0.0-beta.6>

Environment data

Windows 10 Insider Build 16257
Ubuntu 16.04.3 LTS
openssh 0.0.19.0

PS C:\Program Files\PowerShell\6.0.0-beta.6> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      6.0.0-beta
PSEdition                      Core
GitCommitId                    v6.0.0-beta.6
OS                             Microsoft Windows 10.0.16275
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

psession_exit_error

Activity

  1. added
    WG-Remoting
    on Aug 28, 2017
  2. added this to the milestone on Aug 28, 2017
  3. iSazonov commented on Aug 28, 2017

    @iSazonov
    Collaborator

    /cc Paul Higinbotham (@PaulHigin) Could you please look the Issue - it seems we should catch the exception.

  4. PaulHigin commented on Aug 28, 2017

    @PaulHigin
    Contributor

    Maximo Trinidad (@MaximoTrinidad)
    Thanks for reporting this. This is a regression I introduced with #4475. The CloseAsync() method should not prematurely clean up connection state unless a connection was never established, and this is causing the exception to be thrown. I have a fix for it and I'll create a PR soon.

  5. modified the milestones: , on Aug 28, 2017
  6. iSazonov commented on Sep 12, 2017

    @iSazonov
    Collaborator

    Paul Higinbotham (@PaulHigin) Can we close the Issue?

  7. PaulHigin commented on Sep 12, 2017

    @PaulHigin
    Contributor

    Yes, the fix has been merged. Thanks.

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

Metadata

Metadata

Labels

Resolution-FixedWG-Remoting

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions