Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Azure Bastion SSH and Tunnel fails with "nodename nor servname provided, or not known" #6707

Open
limenet opened this issue Aug 30, 2023 · 4 comments
Assignees
Labels
Auto-Assign Auto assign by bot Azure CLI Team The command of the issue is owned by Azure CLI team customer-reported Issues that are reported by GitHub users external to the Azure organization. Network - Bastion Network question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Attention This issue is responsible by Azure service team.

Comments

@limenet
Copy link

limenet commented Aug 30, 2023

Describe the bug

When I try to establish an SSH session via Bastion on macOS the command fails. The same behavior also occurs when executing az network bastion tunnel.

When running the command from inside a Docker container on the same machine with the same credentials, it works. When running sudo lsof -i -P, I can't find any obvious port conflicts. The behavior is reproducible after a reboot.

Related command

az network bastion ssh --name {} --resource-group {} --target-resource-id {} --username {} --auth-type {}

Errors

The command failed with an unexpected error. Here is the traceback:
[Errno 8] nodename nor servname provided, or not known
Traceback (most recent call last):
  File "/opt/homebrew/Cellar/azure-cli/2.50.0_1/libexec/lib/python3.10/site-packages/knack/cli.py", line 233, in invoke
    cmd_result = self.invocation.execute(args)
  File "/opt/homebrew/Cellar/azure-cli/2.50.0_1/libexec/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 663, in execute
    raise ex
  File "/opt/homebrew/Cellar/azure-cli/2.50.0_1/libexec/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 726, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
  File "/opt/homebrew/Cellar/azure-cli/2.50.0_1/libexec/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 697, in _run_job
    result = cmd_copy(params)
  File "/opt/homebrew/Cellar/azure-cli/2.50.0_1/libexec/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 333, in __call__
    return self.handler(*args, **kwargs)
  File "/opt/homebrew/Cellar/azure-cli/2.50.0_1/libexec/lib/python3.10/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler
    return op(**command_args)
  File "/Users/xxx/.azure/cliextensions/bastion/azext_bastion/custom.py", line 163, in ssh_bastion_host
    tunnel_server = _get_tunnel(cmd, bastion, bastion_endpoint, target_resource_id, resource_port)
  File "/Users/xxx/.azure/cliextensions/bastion/azext_bastion/custom.py", line 329, in _get_tunnel
    tunnel_server = TunnelServer(cmd.cli_ctx, "localhost", port, bastion, bastion_endpoint, vm_id, resource_port)
  File "/Users/xxx/.azure/cliextensions/bastion/azext_bastion/tunnel.py", line 62, in __init__
    self.sock.bind((self.local_addr, self.local_port))
socket.gaierror: [Errno 8] nodename nor servname provided, or not known

Issue script & Debug output

cli.knack.cli: Command arguments: [REDACTED]
cli.knack.cli: __init__ debug log:
Enable color in terminal.
cli.knack.cli: Event: Cli.PreExecute []
cli.knack.cli: Event: CommandParser.OnGlobalArgumentsCreate [<function CLILogging.on_global_arguments at 0x101031b40>, <function OutputProducer.on_global_arguments at 0x1010ba710>, <function CLIQuery.on_global_arguments at 0x101327b50>]
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.381       115       353
cli.azure.cli.core: privatedns                0.002        14        66
cli.azure.cli.core: Total (2)                 0.383       129       419
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.005         2         9  /Users/xxx/.azure/cliextensions/bastion
cli.azure.cli.core: Total (1)                 0.005         2         9
cli.azure.cli.core: Loaded 129 groups, 428 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 [<function AzCliLogging.init_command_file_logging at 0x1027796c0>]
cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to '/Users/xxx/.azure/commands/2023-08-30.16-09-53.network_bastion_ssh.54015.log'.
az_command_data_logger: command args: network bastion ssh --name {} --resource-group {} --target-resource-id {} --username {} --auth-type {} --debug
cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [<function register_global_subscription_argument.<locals>.add_subscription_parameter at 0x102792050>]
cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad []
cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [<function register_ids_argument.<locals>.add_ids_arguments at 0x1027bfb50>, <function register_cache_arguments.<locals>.add_cache_arguments at 0x1027bfc70>]
cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded []
cli.knack.cli: Event: CommandInvoker.OnPreParseArgs []
cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [<function OutputProducer.handle_output_argument at 0x1010ba7a0>, <function CLIQuery.handle_query_parameter at 0x101327be0>, <function register_ids_argument.<locals>.parse_ids_arguments at 0x1027bfbe0>]
az_command_data_logger: extension name: bastion
az_command_data_logger: extension version: 0.2.5
Command group 'az network' is in preview and under development. Reference and support levels: https://aka.ms/CLI_refstatus
cli.azure.cli.core.auth.persistence: build_persistence: location='/Users/xxx/.azure/msal_token_cache.json', encrypt=False
cli.azure.cli.core.auth.binary_cache: load: /Users/linus/.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: openid_config = [REDACTED]
msal.application: Broker enabled? False
cli.azure.cli.core.auth.credential_adaptor: CredentialAdaptor.get_token: scopes=('https://management.core.windows.net//.default',), kwargs={}
cli.azure.cli.core.auth.msal_authentication: UserCredential.get_token: scopes=('https://management.core.windows.net//.default',), claims=None, kwargs={}
msal.application: Cache hit an AT
msal.telemetry: Generate or reuse correlation_id: 843a59c1-b461-42eb-8556-ecc208e59d4d
cli.azure.cli.core.sdk.policies: Request URL: '[REDACTED]'
cli.azure.cli.core.sdk.policies: Request method: 'GET'
cli.azure.cli.core.sdk.policies: Request headers: [REDACTED]
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 [REDACTED]?api-version=2022-01-01 HTTP/1.1" 200 None
cli.azure.cli.core.sdk.policies: Response status: 200
cli.azure.cli.core.sdk.policies: Response headers: [REDACTED]
cli.azure.cli.core.sdk.policies: Response content: [REDACTED]
cli.azext_bastion.tunnel: Creating a socket on port: 0
cli.azext_bastion.tunnel: Setting socket options
cli.azext_bastion.tunnel: Binding to socket on local address and port
cli.azure.cli.core.azclierror: Traceback (most recent call last):
  File "/opt/homebrew/Cellar/azure-cli/2.50.0_1/libexec/lib/python3.10/site-packages/knack/cli.py", line 233, in invoke
    cmd_result = self.invocation.execute(args)
  File "/opt/homebrew/Cellar/azure-cli/2.50.0_1/libexec/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 663, in execute
    raise ex
  File "/opt/homebrew/Cellar/azure-cli/2.50.0_1/libexec/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 726, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
  File "/opt/homebrew/Cellar/azure-cli/2.50.0_1/libexec/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 697, in _run_job
    result = cmd_copy(params)
  File "/opt/homebrew/Cellar/azure-cli/2.50.0_1/libexec/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 333, in __call__
    return self.handler(*args, **kwargs)
  File "/opt/homebrew/Cellar/azure-cli/2.50.0_1/libexec/lib/python3.10/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler
    return op(**command_args)
  File "/Users/xxx/.azure/cliextensions/bastion/azext_bastion/custom.py", line 163, in ssh_bastion_host
    tunnel_server = _get_tunnel(cmd, bastion, bastion_endpoint, target_resource_id, resource_port)
  File "/Users/xxx/.azure/cliextensions/bastion/azext_bastion/custom.py", line 329, in _get_tunnel
    tunnel_server = TunnelServer(cmd.cli_ctx, "localhost", port, bastion, bastion_endpoint, vm_id, resource_port)
  File "/Users/xxx/.azure/cliextensions/bastion/azext_bastion/tunnel.py", line 62, in __init__
    self.sock.bind((self.local_addr, self.local_port))
socket.gaierror: [Errno 8] nodename nor servname provided, or not known

cli.azure.cli.core.azclierror: The command failed with an unexpected error. Here is the traceback:
az_command_data_logger: The command failed with an unexpected error. Here is the traceback:
cli.azure.cli.core.azclierror: [Errno 8] nodename nor servname provided, or not known
Traceback (most recent call last):
  File "/opt/homebrew/Cellar/azure-cli/2.50.0_1/libexec/lib/python3.10/site-packages/knack/cli.py", line 233, in invoke
    cmd_result = self.invocation.execute(args)
  File "/opt/homebrew/Cellar/azure-cli/2.50.0_1/libexec/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 663, in execute
    raise ex
  File "/opt/homebrew/Cellar/azure-cli/2.50.0_1/libexec/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 726, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
  File "/opt/homebrew/Cellar/azure-cli/2.50.0_1/libexec/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 697, in _run_job
    result = cmd_copy(params)
  File "/opt/homebrew/Cellar/azure-cli/2.50.0_1/libexec/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 333, in __call__
    return self.handler(*args, **kwargs)
  File "/opt/homebrew/Cellar/azure-cli/2.50.0_1/libexec/lib/python3.10/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler
    return op(**command_args)
  File "/Users/xxx/.azure/cliextensions/bastion/azext_bastion/custom.py", line 163, in ssh_bastion_host
    tunnel_server = _get_tunnel(cmd, bastion, bastion_endpoint, target_resource_id, resource_port)
  File "/Users/xxx/.azure/cliextensions/bastion/azext_bastion/custom.py", line 329, in _get_tunnel
    tunnel_server = TunnelServer(cmd.cli_ctx, "localhost", port, bastion, bastion_endpoint, vm_id, resource_port)
  File "/Users/xxx/.azure/cliextensions/bastion/azext_bastion/tunnel.py", line 62, in __init__
    self.sock.bind((self.local_addr, self.local_port))
socket.gaierror: [Errno 8] nodename nor servname provided, or not known
az_command_data_logger: [Errno 8] nodename nor servname provided, or not known
Traceback (most recent call last):
  File "/opt/homebrew/Cellar/azure-cli/2.50.0_1/libexec/lib/python3.10/site-packages/knack/cli.py", line 233, in invoke
    cmd_result = self.invocation.execute(args)
  File "/opt/homebrew/Cellar/azure-cli/2.50.0_1/libexec/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 663, in execute
    raise ex
  File "/opt/homebrew/Cellar/azure-cli/2.50.0_1/libexec/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 726, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
  File "/opt/homebrew/Cellar/azure-cli/2.50.0_1/libexec/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 697, in _run_job
    result = cmd_copy(params)
  File "/opt/homebrew/Cellar/azure-cli/2.50.0_1/libexec/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 333, in __call__
    return self.handler(*args, **kwargs)
  File "/opt/homebrew/Cellar/azure-cli/2.50.0_1/libexec/lib/python3.10/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler
    return op(**command_args)
  File "/Users/xxx/.azure/cliextensions/bastion/azext_bastion/custom.py", line 163, in ssh_bastion_host
    tunnel_server = _get_tunnel(cmd, bastion, bastion_endpoint, target_resource_id, resource_port)
  File "/Users/xxx/.azure/cliextensions/bastion/azext_bastion/custom.py", line 329, in _get_tunnel
    tunnel_server = TunnelServer(cmd.cli_ctx, "localhost", port, bastion, bastion_endpoint, vm_id, resource_port)
  File "/Users/xxx/.azure/cliextensions/bastion/azext_bastion/tunnel.py", line 62, in __init__
    self.sock.bind((self.local_addr, self.local_port))
socket.gaierror: [Errno 8] nodename nor servname provided, or not known
To check existing issues, please visit: https://github.com/Azure/azure-cli/issues
cli.knack.cli: Event: Cli.PostExecute [<function AzCliLogging.deinit_cmd_metadata_logging at 0x102779900>]
az_command_data_logger: exit code: 1
cli.__main__: Command ran in 1.109 seconds (init: 0.101, invoke: 1.008)
telemetry.main: Begin splitting cli events and extra events, total events: 1
telemetry.client: Accumulated 0 events. Flush the clients.
telemetry.main: Finish splitting cli events and extra events, cli events: 1
telemetry.save: Save telemetry record of length 7483 in cache
telemetry.check: Negative: The /Users/xxx/.azure/telemetry.txt was modified at 2023-08-30 16:05:23.719328, which in less than 600.000000 s

Expected behavior

SSH connection is established.

Environment Summary

macOS-13.5.1-arm64-arm-64bit, Darwin 22.6.0
Python 3.10.13
Installer: HOMEBREW

azure-cli 2.50.0 *

Extensions:
bastion 0.2.5
ssh 2.0.1

Dependencies:
msal 1.22.0
azure-mgmt-resource 23.1.0b2

Additional context

No response

@limenet limenet added the bug This issue requires a change to an existing behavior in the product in order to be resolved. label Aug 30, 2023
@microsoft-github-policy-service microsoft-github-policy-service bot added question The issue doesn't require a change to the product in order to be resolved. Most issues start as that customer-reported Issues that are reported by GitHub users external to the Azure organization. Network labels Aug 30, 2023
@microsoft-github-policy-service microsoft-github-policy-service bot added Auto-Assign Auto assign by bot Azure CLI Team The command of the issue is owned by Azure CLI team CXP Attention This issue is handled by CXP team. labels Aug 30, 2023
@yonzhan
Copy link
Collaborator

yonzhan commented Aug 30, 2023

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

@yonzhan yonzhan removed the bug This issue requires a change to an existing behavior in the product in order to be resolved. label Aug 30, 2023
@faridmv
Copy link

faridmv commented Sep 11, 2023

Hello,
Is there any update about this issue? I have the same problem. How can I solve it?

@kkk-an
Copy link

kkk-an commented Sep 22, 2023

so what's wrong with this? and how can I solve it? tks

@PramodValavala-MSFT PramodValavala-MSFT added Service Attention This issue is responsible by Azure service team. and removed CXP Attention This issue is handled by CXP team. labels Sep 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Auto-Assign Auto assign by bot Azure CLI Team The command of the issue is owned by Azure CLI team customer-reported Issues that are reported by GitHub users external to the Azure organization. Network - Bastion Network question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Attention This issue is responsible by Azure service team.
Projects
None yet
Development

No branches or pull requests

6 participants