Skip to content

Adding Service Principal Support to SSH Adjacent Services#29535

Open
DevanshG1 wants to merge 1 commit intoAzure:mainfrom
DevanshG1:personal/degoswami/Adding_SP_and_MI_Support_For_SSH
Open

Adding Service Principal Support to SSH Adjacent Services#29535
DevanshG1 wants to merge 1 commit intoAzure:mainfrom
DevanshG1:personal/degoswami/Adding_SP_and_MI_Support_For_SSH

Conversation

@DevanshG1
Copy link
Copy Markdown
Contributor

@DevanshG1 DevanshG1 commented May 8, 2026

Description

Mandatory Checklist

  • SHOULD update ChangeLog.md file(s) appropriately
    • Update src/{{SERVICE}}/{{SERVICE}}/ChangeLog.md.
      • A snippet outlining the change(s) made in the PR should be written under the ## Upcoming Release header in the past tense.
    • Should not change ChangeLog.md if no new release is required, such as fixing test case only.
  • SHOULD regenerate markdown help files if there is cmdlet API change. Instruction
  • SHOULD have proper test coverage for changes in pull request.
  • SHOULD NOT adjust version of module manually in pull request

Copilot AI review requested due to automatic review settings May 8, 2026 05:11
@azure-client-tools-bot-prd
Copy link
Copy Markdown

Thanks for your contribution! The pull request validation has started. Please revisit this comment for updated status.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enables SSH certificate acquisition (for Microsoft Entra ID login) when the current Az context is authenticated as a Service Principal, extending the existing user-only flow. It updates the shared authentication factory to use MSAL confidential client flows, relaxes prior account-type restrictions in SSH/SFTP modules, and adds scenario tests plus changelog entries.

Changes:

  • Updated SshCredentialFactory to acquire SSH-cert access tokens for ServicePrincipal accounts (confidential client) in addition to User accounts (public client).
  • Relaxed SSH/SFTP certificate generation error handling to allow Service Principal contexts (and to wrap additional exception types).
  • Added SFTP scenario tests for factory interaction and updated module changelogs.

Reviewed changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
src/Ssh/Ssh/Common/SshBaseCmdlet.cs Broadens exception handling to allow Service Principal flows by removing the user-only restriction path.
src/Ssh/Ssh/ChangeLog.md Documents Service Principal support for SSH Entra ID certificate auth.
src/Sftp/Sftp/Common/FileUtils.cs Broadens exception handling to allow Service Principal flows and standardizes wrapped errors.
src/Sftp/Sftp/CHANGELOG.md Documents Service Principal support for SFTP Entra ID certificate auth.
src/Sftp/Sftp.Test/ScenarioTests/FileUtilsTests.cs Adds scenario tests to validate Service Principal and user flows through the credential factory.
src/Accounts/Authentication/Properties/Resources.resx Adds localized strings for unsupported account type and missing SP credentials.
src/Accounts/Authentication/Properties/Resources.Designer.cs Generated resource accessors for new localized strings.
src/Accounts/Authentication/Factories/SshCredentialFactory.cs Implements Service Principal SSH-cert acquisition via confidential client + authentication extension.
src/Accounts/Authentication/Authentication/TokenCache/PowerShellTokenCacheProvider.cs Adds confidential client construction helpers for client secret/certificate flows.
src/Accounts/Accounts/ChangeLog.md Documents the Accounts-side factory enhancement enabling SP automation scenarios.
Files not reviewed (1)
  • src/Accounts/Authentication/Properties/Resources.Designer.cs: Language not supported

using System;
using System.Collections.Generic;
using System.Linq;
using System.Security;
Comment thread src/Accounts/Authentication/Factories/SshCredentialFactory.cs
Comment on lines +137 to +151
if (certificate != null)
{
return tokenCacheProvider.CreateConfidentialClient(authority, tenantId, clientId, certificate);
}
}

// Try certificate path
string certificatePath = context.Account.GetProperty(AzureAccount.Property.CertificatePath);
if (!string.IsNullOrEmpty(certificatePath))
{
SecureString certificatePassword = GetServicePrincipalSecureString(context, AzureAccount.Property.CertificatePassword);
X509Certificate2 certificate = certificatePassword != null
? new X509Certificate2(certificatePath, certificatePassword)
: new X509Certificate2(certificatePath);
return tokenCacheProvider.CreateConfidentialClient(authority, tenantId, clientId, certificate);
Comment thread src/Sftp/Sftp.Test/ScenarioTests/FileUtilsTests.cs
Comment thread src/Sftp/Sftp.Test/ScenarioTests/FileUtilsTests.cs
Comment thread src/Sftp/Sftp.Test/ScenarioTests/FileUtilsTests.cs
Comment thread src/Ssh/Ssh/ChangeLog.md
Comment thread src/Sftp/Sftp/CHANGELOG.md
Comment thread src/Accounts/Accounts/ChangeLog.md
@VeryEarly
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown
Contributor

Azure Pipelines successfully started running 3 pipeline(s).

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants