Skip to content

DPAPI in Remote PSSession from Linux to Windows #11011

Closed

Description

Using DPAPI in a remote PSSession requires using -Authentication Credssp so that the creds are forwarded.

Creating a remote session from Linux to Windows only works using -Authentication Negotiate. This precludes the use of DPAPI.

As a user I want to be able to encrypt data using DPAPI in a remote session created from a Linux host so that I can secure my data.

I appreciate this would be non-trivial to achieve but I have no idea if is is even feasible at all.

Activity

  1. added
    Issue-Enhancement
    on Nov 7, 2019
  2. hrobertson commented on Nov 7, 2019

    @hrobertson
    Author

    I tried to 'forward' the credentials myself as follows:

    $Credential = New-Object System.Management.Automation.PSCredential -ArgumentList @(
        'myusername', 
        (ConvertTo-SecureString -String 'mypassword' -AsPlainText -Force)
    )
    $Session = New-PSSession -ComputerName $RemoteHost -Credential $Credential -Authentication Negotiate
    Invoke-Command -Session $Session -ScriptBlock{                                                         
        $RemoteSession = New-PSSession -Credential $using:Credential
    }

    But the following error is thrown:

    Invoke-Command : Session key not available to encrypt secure string.
    At line:1 char:1
    + Invoke-Command -Session $Session -ScriptBlock{
    +      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Invoke-Command], PSCryptoException
    + FullyQualifiedErrorId : System.Management.Automation.Internal.PSCryptoException,Microsoft.PowerShell.Commands.InvokeCommandCommand
    
  3. iSazonov commented on Nov 9, 2019

    @iSazonov
    Collaborator

    See #1654. DPAPI is Windows only API and will be never ported on Unix. SecureString formally is on Unix but encrypt nothing.
    You could feedback in the proposed RFC PowerShell/PowerShell-RFC#208

  4. added
    Issue-Question
    Resolution-Answered
    and removed
    Issue-Enhancement
    on Nov 9, 2019
  5. hrobertson commented on Nov 9, 2019

    @hrobertson
    Author

    Ilya (@iSazonov) Thank you for your reply but I think you've missed that I'm not asking for DPAPI to be ported to *nix. - I'm wanting to use DPAPI on Windows, I just happen to be in a remote session from a Linux box.

    If anything, I'd be asking for CredSSP to be ported to *nix but I know that's probably not going to happen. So this request is for an alternative.

  6. iSazonov commented on Nov 9, 2019

    @iSazonov
    Collaborator

    From my understading you run New-PSSession on Unix. In the case the cmdlet would use DPAPI locally on Unix to protect data that is impossible.

  7. ghost closed this as completedon Nov 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-QuestionResolution-Answered

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions