Skip to content

Win32 OpenSSH cross domain authentication via public key #2421

@robertstrom

Description

@robertstrom

Prerequisites

  • Write a descriptive title.
  • Make sure you are able to repro it on the latest version
  • Search the existing issues.

Steps to reproduce

I have a multi-domain environment. There is currently no trust between these domains.

The server that I am trying to connect to is running:

Microsoft Windows Server 2019 Standard
OpenSSH_for_Windows_9.5p2, LibreSSL 3.8.2

I have copied the public key over to the administrators_authorized_keys file using the documented method on this page - https://learn.microsoft.com/en-us/windows-server/administration/openssh/openssh_keymanagement - except that there needs to be some modification to make the copying of the SSH key work. I have found that this part needs to be modified:

Original:

$remotePowershell = "powershell Add-Content -Force -Path $env:ProgramData\ssh\administrators_authorized_keys -Value '''$authorizedKey''';icacls.exe ""$env:ProgramData\ssh\administrators_authorized_keys"" /inheritance:r /grant ""Administrators:F"" /grant ""SYSTEM:F"""

Modified:

$remotePowershell = "powershell Add-Content -Force -Path $env:ProgramData\ssh\administrators_authorized_keys -Value '$authorizedKey';icacls.exe ""$env:ProgramData\ssh\administrators_authorized_keys"" /inheritance:r /grant ""Administrators:F"" /grant ""SYSTEM:F"""

Only one set of single quotes around the $authorizedKey variable. Without doing this the administrators_authorized_keys file ends up having single quotes around the public key. I have used this modification successfully in the domain that my workstation is associated with so I know that it generally works. I can also just copy over the SSH public key.

Here's the scenario:

  • My workstation is an EntraAD joined machine (not hybrid joined) but there is an association with the main domain
  • I can use the method described above to copy over my public SSH key to a server and I can then connect to it without having to use a password
  • My SSH public key is for my standard domain user account but it is placed in the administrators_authorized_keys file and I can log in without using a password using adminaccount@servername.fqdn
  • Now I try to connect to a machine in the QA domain (there are no domain trusts between these domains) with the same SSH public key in the QA domain server administrators_authorized_keys file and I am prompted for a password
  • That is not the behavior that I was expecting. I figured that an SSH key would validate me regardless

I find very little to no documentation on cross domain SSH authentication via public key.

I have also setup the SSH access to Azure Arc-enabled servers successfully in the main domain and also configured a server in the QA domain (both servers are in the same Azure Tenant and the same Azure Arc RG).

The command below works for the main domain but not for the QA domain. I am prompted for the users password when trying to connect to the QA domain server

az ssh arc -g <resource group>  --n <ARC server name> --local-user <user name>
  • Is cross domain SSH public key authentication supported?
  • If so, how do I make it work?
  • Is there documentation pertaining to cross domain SSH public key authentication?
  • When will SSH authentication with Microsoft Entra ID be available for WIndows?
  • When SSH authentication with Microsoft Entra ID is available for Windows will it work in the cross domain scenario that I am describing?

Expected behavior

Be able to use an SSH key universally across any machine where the public key has been deployed

Actual behavior

I'm prompted for the password for the users password when attempting to login to the QA domain server regardless of whether I am using a standard SSH or an Azure Arc ssh connection method.

Error details

Environment data

This QA machine that is currently failing is currently configured to present the standard CMD shell upon SSH login. I have configured the other domain machine that is working to default to PowerShell 7 as the default shell.


Name                           Value
----                           -----
PSVersion                      7.5.3
PSEdition                      Core
GitCommitId                    7.5.3
OS                             Microsoft Windows 10.0.17763
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

and

Name                           Value
----                           -----
PSVersion                      5.1.17763.8146
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.17763.8146
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Version

OpenSSH_for_Windows_9.5p2, LibreSSL 3.8.2

Visuals

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions