Skip to content

[SSH] Restore explicit failure for unsupported managed identity and Cloud Shell SSH cert flows#33334

Draft
Copilot wants to merge 2 commits intodevfrom
copilot/fix-ssh-error-azure-vm
Draft

[SSH] Restore explicit failure for unsupported managed identity and Cloud Shell SSH cert flows#33334
Copilot wants to merge 2 commits intodevfrom
copilot/fix-ssh-error-azure-vm

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 8, 2026

Related command

az ssh vm
az ssh cert

Description

az ssh vm / az ssh cert could fall through Profile.get_msal_token() on managed identity and Cloud Shell accounts and pass an access token to the ssh extension as if it were an OpenSSH certificate. That produced a malformed *-aadcert.pub file and surfaced as ssh-keygen ... invalid format instead of the intended user-facing error.

  • Core guard restored

    • Reintroduce the VM SSH account-type check in azure-cli-core before certificate acquisition.
    • Reject managed identity and Cloud Shell accounts with the existing explicit error:
      • VM SSH currently doesn't support managed identity or Cloud Shell.
  • Behavioral impact

    • Prevents invalid AAD SSH certificate files from being written for unsupported account types.
    • Converts an unexpected traceback into a deterministic, actionable failure at the auth boundary.
  • Regression coverage

    • Add focused unit tests for:
      • managed identity account
      • Cloud Shell account
      • existing supported user-based SSH certificate flow
def get_msal_token(self, scopes, data):
    account = self.get_subscription()
    managed_identity_type, _ = Profile._parse_managed_identity_account(account)
    if managed_identity_type or (in_cloud_console() and account[_USER_ENTITY].get(_CLOUD_SHELL_ID)):
        raise AuthenticationError("VM SSH currently doesn't support managed identity or Cloud Shell.")

Testing Guide

# Unsupported account types now fail explicitly instead of producing an invalid SSH cert file
az login --identity
az ssh cert --public-key-file ~/.ssh/id_rsa.pub
# Expected: VM SSH currently doesn't support managed identity or Cloud Shell.

# Existing supported user flow is unchanged
az login
az ssh cert --public-key-file ~/.ssh/id_rsa.pub

History Notes

[SSH] az ssh vm: Restore explicit error for managed identity and Cloud Shell account flows instead of generating an invalid AAD SSH certificate


This checklist is used to make sure that common guidelines for a pull request are followed.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • azcliprod.blob.core.windows.net
    • Triggering command: /usr/bin/python python -m unittest azure.cli.core.tests.test_profile.TestProfile.test_get_msal_token (dns block)
    • Triggering command: /usr/bin/python python -m unittest azure.cli.core.tests.test_profile.TestProfile.test_get_raw_token_mi_system_assigned azure.cli.core.tests.test_profile.TestProfile.test_get_raw_token_in_cloud_shell (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@azure-client-tools-bot-prd
Copy link
Copy Markdown

azure-client-tools-bot-prd Bot commented May 8, 2026

️✔️AzureCLI-FullTest
️✔️acr
️✔️latest
️✔️3.12
️✔️3.13
️✔️acs
️✔️latest
️✔️3.12
️✔️3.13
️✔️advisor
️✔️latest
️✔️3.12
️✔️3.13
️✔️ams
️✔️latest
️✔️3.12
️✔️3.13
️✔️apim
️✔️latest
️✔️3.12
️✔️3.13
️✔️appconfig
️✔️latest
️✔️3.12
️✔️3.13
️✔️appservice
️✔️latest
️✔️3.12
️✔️3.13
️✔️aro
️✔️latest
️✔️3.12
️✔️3.13
️✔️backup
️✔️latest
️✔️3.12
️✔️3.13
️✔️batch
️✔️latest
️✔️3.12
️✔️3.13
️✔️batchai
️✔️latest
️✔️3.12
️✔️3.13
️✔️billing
️✔️latest
️✔️3.12
️✔️3.13
️✔️botservice
️✔️latest
️✔️3.12
️✔️3.13
️✔️cdn
️✔️latest
️✔️3.12
️✔️3.13
️✔️cloud
️✔️latest
️✔️3.12
️✔️3.13
️✔️cognitiveservices
️✔️latest
️✔️3.12
️✔️3.13
️✔️compute_recommender
️✔️latest
️✔️3.12
️✔️3.13
️✔️computefleet
️✔️latest
️✔️3.12
️✔️3.13
️✔️config
️✔️latest
️✔️3.12
️✔️3.13
️✔️configure
️✔️latest
️✔️3.12
️✔️3.13
️✔️consumption
️✔️latest
️✔️3.12
️✔️3.13
️✔️container
️✔️latest
️✔️3.12
️✔️3.13
️✔️containerapp
️✔️latest
️✔️3.12
️✔️3.13
️✔️core
️✔️latest
️✔️3.12
️✔️3.13
️✔️cosmosdb
️✔️latest
️✔️3.12
️✔️3.13
️✔️databoxedge
️✔️latest
️✔️3.12
️✔️3.13
️✔️dls
️✔️latest
️✔️3.12
️✔️3.13
️✔️dms
️✔️latest
️✔️3.12
️✔️3.13
️✔️eventgrid
️✔️latest
️✔️3.12
️✔️3.13
️✔️eventhubs
️✔️latest
️✔️3.12
️✔️3.13
️✔️feedback
️✔️latest
️✔️3.12
️✔️3.13
️✔️find
️✔️latest
️✔️3.12
️✔️3.13
️✔️hdinsight
️✔️latest
️✔️3.12
️✔️3.13
️✔️identity
️✔️latest
️✔️3.12
️✔️3.13
️✔️iot
️✔️latest
️✔️3.12
️✔️3.13
️✔️keyvault
️✔️latest
️✔️3.12
️✔️3.13
️✔️lab
️✔️latest
️✔️3.12
️✔️3.13
️✔️managedservices
️✔️latest
️✔️3.12
️✔️3.13
️✔️maps
️✔️latest
️✔️3.12
️✔️3.13
️✔️marketplaceordering
️✔️latest
️✔️3.12
️✔️3.13
️✔️monitor
️✔️latest
️✔️3.12
️✔️3.13
️✔️mysql
️✔️latest
️✔️3.12
️✔️3.13
️✔️netappfiles
️✔️latest
️✔️3.12
️✔️3.13
️✔️network
️✔️latest
️✔️3.12
️✔️3.13
️✔️policyinsights
️✔️latest
️✔️3.12
️✔️3.13
️✔️postgresql
️✔️latest
️✔️3.12
️✔️3.13
️✔️privatedns
️✔️latest
️✔️3.12
️✔️3.13
️✔️profile
️✔️latest
️✔️3.12
️✔️3.13
️✔️rdbms
️✔️latest
️✔️3.12
️✔️3.13
️✔️redis
️✔️latest
️✔️3.12
️✔️3.13
️✔️relay
️✔️latest
️✔️3.12
️✔️3.13
️✔️resource
️✔️latest
️✔️3.12
️✔️3.13
️✔️role
️✔️latest
️✔️3.12
️✔️3.13
️✔️search
️✔️latest
️✔️3.12
️✔️3.13
️✔️security
️✔️latest
️✔️3.12
️✔️3.13
️✔️servicebus
️✔️latest
️✔️3.12
️✔️3.13
️✔️serviceconnector
️✔️latest
️✔️3.12
️✔️3.13
️✔️servicefabric
️✔️latest
️✔️3.12
️✔️3.13
️✔️signalr
️✔️latest
️✔️3.12
️✔️3.13
️✔️sql
️✔️latest
️✔️3.12
️✔️3.13
️✔️sqlvm
️✔️latest
️✔️3.12
️✔️3.13
️✔️storage
️✔️latest
️✔️3.12
️✔️3.13
️✔️synapse
️✔️latest
️✔️3.12
️✔️3.13
️✔️telemetry
️✔️latest
️✔️3.12
️✔️3.13
️✔️util
️✔️latest
️✔️3.12
️✔️3.13
️✔️vm
️✔️latest
️✔️3.12
️✔️3.13

@azure-client-tools-bot-prd
Copy link
Copy Markdown

azure-client-tools-bot-prd Bot commented May 8, 2026

️✔️AzureCLI-BreakingChangeTest
️✔️Non Breaking Changes

Copilot AI changed the title [WIP] Fix SSH error for Azure VM using AAD [SSH] Restore explicit failure for unsupported managed identity and Cloud Shell SSH cert flows May 8, 2026
Copilot AI requested a review from a0x1ab May 8, 2026 05:48
Copilot finished work on behalf of a0x1ab May 8, 2026 05:48
@yonzhan
Copy link
Copy Markdown
Collaborator

yonzhan commented May 8, 2026

SSH

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unable to SSH the Azure VM using AAD

4 participants