Azure / Azure/azure-cli-extensions

[bastion] `az network bastion ssh (...) --auth-type password` uses public key authentication on localhost

Open
#10,005 2 comments 1 reaction 3 assignees Claimed by @necusjz View on GitHub
Auto-Assign Network Network - Bastion question Service Attention
Dominant language
Python
Stars
454
Forks
1.7k
Avg merge
2d 19h
Merged PRs (30d)
64

Description

Source: https://github.com/Azure/azure-cli/issues/32776 (by @FlorentATo)
Affected extension: `bastion` (`src/bastion/`)

---

<<>>
# Issue #32776 (by @FlorentATo)
## Title
`az network bastion ssh (...) --auth-type password` uses public key authentication on localhost

## Body
### Describe the bug

I'm trying to connect to a Linux VM deployed behind Azure Bastion using `az network bastion ssh`. For the purpose of this test, sshd is configured to accept password-based authentication for SSH.

When running `az network bastion ssh --name --resource-group --target-resource-id --auth-type password --username `, it appears that the Azure CLI tries to connect on the local (tunnel) port using public Key authentication instead of password authentication.

Note: I don't have any entry for "localhost" in my `.ssh/config`.

### Related command

az network bastion ssh

### Errors

'''
➜ ~ az network bastion ssh --name {REDACTED} --resource-group {REDACTED} --target-resource-id {REDACTED} --auth-type password --username ftatard
/Users/florenttatard/.azure/cliextensions/bastion/azext_bastion/custom.py:107: UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81.
from pkg_resources import parse_version
ftatard@localhost: Permission denied (publickey).
'''

### Issue script & Debug output

'''
➜ ~ az network bastion ssh --name {REDACTED} --resource-group {REDACTED} --target-resource-id {REDACTED} --auth-type password --username ftatard --debug
cli.knack.cli: Command arguments: ['network', 'bastion', 'ssh', '--name', '{REDACTED}', '--resource-group', '{REDACTED}', '--target-resource-id', '/subscriptions/{REDACTED}/resourceGroups/{REDACTED}/providers/Microsoft.Compute/virtualMachines/vm-client-data-access-prod', '--auth-type', 'password', '--username', 'ftatard', '--debug']
cli.knack.cli: __init__ debug log:
Enable color in terminal.
cli.knack.cli: Event: Cli.PreExecute []
cli.knack.cli: Event: CommandParser.OnGlobalArgumentsCreate [, , ]
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate []
cli.azure.cli.core: Modules found from index for 'network': ['azure.cli.command_modules.network', 'azure.cli.command_modules.privatedns', 'azext_bastion']
cli.azure.cli.core: Loading command modules:
cli.azure.cli.core: Name Load Time Groups Commands
cli.azure.cli.core: network 0.161 122 370
cli.azure.cli.core: privatedns 0.004 14 60
cli.azure.cli.core: Total (2) 0.165 136 430
cli.azure.cli.core: These extensions are not installed and will be skipped: ['azext_ai_examples', 'azext_next']
cli.azure.cli.core: Loading extensions:
cli.azure.cli.core: Name Load Time Groups Commands Directory
cli.azure.cli.core: bastion 0.002 2 9 /Users/{REDACTED}/.azure/cliextensions/bastion
cli.azure.cli.core: Total (1) 0.002 2 9
cli.azure.cli.core: Loaded 136 groups, 439 commands.
cli.azure.cli.core: Found a match in the command table.
cli.azure.cli.core: Raw command : network bastion ssh
cli.azure.cli.core: Command table: network bastion ssh
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate []
cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to '/Users/{REDACTED}/.azure/commands/2026-02-11.13-49-56.network_bastion_ssh.47320.log'.
az_command_data_logger: command args: network bastion ssh --name {} --resource-group {} --target-resource-id {} --auth-type {} --username {} --debug
cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [.add_subscription_parameter at 0x1069e0b80>]
cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad []
cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [.add_ids_arguments at 0x1069e2e80>, .add_cache_arguments at 0x1069e3060>, .update_breaking_change_info at 0x1069e3100>]
cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded []
cli.knack.cli: Event: CommandInvoker.OnPreParseArgs []
cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [, , .parse_ids_arguments at 0x1069e2f20>]
az_command_data_logger: extension name: bastion
az_command_data_logger: extension version: 1.4.2
/Users/{REDACTED}/.azure/cliextensions/bastion/azext_bastion/custom.py:107: UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81.
from pkg_resources import parse_version
cli.azure.cli.core.auth.persistence: build_persistence: location='/Users/{REDACTED}/.azure/msal_token_cache.json', encrypt=False
cli.azure.cli.core.auth.binary_cache: load: /Users/ftatard/.azure/msal_http_cache.bin
urllib3.util.retry: Converted retries value: 1 -> Retry(total=1, connect=None, read=None, redirect=None, status=None)
msal.authority: Initializing with Entra authority: https://login.microsoftonline.com/1d954bad-21cd-4dbc-8d3c-c8cbcf57251d
msal.authority: {REDACTED}
msal.application: Broker enabled? None
cli.azure.cli.core.auth.credential_adaptor: CredentialAdaptor.get_token: scopes=('https://management.core.windows.net//.default',), kwargs={}
cli.azure.cli.core.auth.msal_credentials: UserCredential.acquire_token: scopes=['https://management.core.windows.net//.default'], claims_challenge=None, kwargs={}
msal.application: Cache hit an AT
msal.telemetry: Generate or reuse correlation_id: adf452c6-cb41-4f86-84b4-0cd040903cd0
cli.azure.cli.core.sdk.policies: Request URL: 'https://management.azure.com/subscriptions/{REDACTED}/resourceGroups/{REDACTED}/providers/Microsoft.Network/bastionHosts/{REDACTED}?api-version=2024-01-01'
cli.azure.cli.core.sdk.policies: Request method: 'GET'
cli.azure.cli.core.sdk.policies: Request headers:
cli.azure.cli.core.sdk.policies: 'Accept': 'application/json'
cli.azure.cli.core.sdk.policies: 'x-ms-client-request-id': '75350fae-077a-11f1-98e5-ce6dc8c0c4fb'
cli.azure.cli.core.sdk.policies: 'CommandName': 'network bastion ssh'
cli.azure.cli.core.sdk.policies: 'ParameterSetName': '--name --resource-group --target-resource-id --auth-type --username --debug'
cli.azure.cli.core.sdk.policies: 'User-Agent': 'AZURECLI/2.83.0 (HOMEBREW) azsdk-python-core/1.38.0 Python/3.13.12 (macOS-15.6-arm64-arm-64bit-Mach-O)'
cli.azure.cli.core.sdk.policies: 'Authorization': '*****'
cli.azure.cli.core.sdk.policies: Request body:
cli.azure.cli.core.sdk.policies: This request has no body
urllib3.connectionpool: Starting new HTTPS connection (1): management.azure.com:443
urllib3.connectionpool: https://management.azure.com:443 "GET /subscriptions/{REDACTED}/resourceGroups/{REDACTED}/providers/Microsoft.Network/bastionHosts/{REDACTED}?api-version=2024-01-01 HTTP/1.1" 200 1677
cli.azure.cli.core.sdk.policies: Response status: 200
cli.azure.cli.core.sdk.policies: Response headers:
cli.azure.cli.core.sdk.policies: 'Cache-Control': 'no-cache'
cli.azure.cli.core.sdk.policies: 'Pragma': 'no-cache'
cli.azure.cli.core.sdk.policies: 'Content-Length': '1677'
cli.azure.cli.core.sdk.policies: 'Content-Type': 'application/json; charset=utf-8'
cli.azure.cli.core.sdk.policies: 'Expires': '-1'
cli.azure.cli.core.sdk.policies: 'ETag': 'W/"cb561851-214d-4548-9508-581e6c8c8bd3"'
cli.azure.cli.core.sdk.policies: 'x-ms-request-id': '127fdbbb-b6fe-4ed0-b5cf-06f5e9c49e9a'
cli.azure.cli.core.sdk.policies:
... [truncated, original was 22781 chars]

## Comments
### Comment by @yonzhan

Thank you for opening this issue, we will look into it.

### Comment by @microsoft-github-policy-service[bot]
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @isamorris, @bastionsuppgithub.

### Comment by @FlorentATo
@yonzhan It's quite frustrating to see this automated reply when dozen of issues from several years ago are still open today and have received **zero follow-up from you** ever since.

I spent a significant amount of my time crawling through all the issues (opened and closed), looking for workarounds. I lost count of how many times I've seen this reply and, to be frank, it simply feels dishonest toward your customers at this point.

You should consider removing this auto-reply if you don't _actually_ plan work on this issue.

My 2 cents.

### Comment by @sebgott
I am seeing this exact same issue with auth type AAD

''' bash
az network bastion ssh --name --resource-group \
--target-resource-id \
--auth-type AAD --subscription "xxx"
'''

Azure-cli versions
''' txt
azure-cli 2.85.0

core 2.85.0
telemetry 1.1.0

Extensions:
bastion 1.4.3
ssh 2.0.7

Dependencies:
msal 1.35.1
azure-mgmt-resource 24.0.0

Python location '/opt/homebrew/Cellar/azure-cli/2.85.0/libexec/bin/python'
Config directory '/Users/x/.azure'
Extensions directory '/Users/x/.azure/cliextensions'

Python (Darwin) 3.13.13 (main, Apr 7 2026, 18:19:01) [Clang 21.0.0 (clang-2100.0.123.102)]

Legal docs and information: aka.ms/AzureCliLegal

Your CLI is up-to-date.
'''

Error

''' bash
s.g@email.com@localhost: Permission denied (publickey).
'''
<<>>

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.