az extension add --name ssh - An error occurred. Pip failed with status code 2
Describe the bug
hello,
I'm going crazy trying to get the ssh extension installed.
I've installed the most recent Azure cli 64 bit from Microsoft's website. I'm trying to utilize Azure arc for RDP to an arc enabled Windows system. I have installed the SSH server addin on the target host.
Below are the commands I'm running (i've left out the values). I'm asked to install the ssh extension, I choose Y. It ends in "An error occurred. Pip failed with status code 2"
az login
az ssh arc --resource-group
The command requires the extension ssh. Do you want to install it now? The command will continue to run after the extension is installed. (Y/n):
An error occurred. Pip failed with status code 2
Related command
az login
az ssh arc --resource-group
Errors
An error occurred. Pip failed with status code 2
Issue script & Debug output
cli.knack.cli: Command arguments: ['ssh', 'arc', '--resource-group', 'oec-east2-dev-it-internal-rg', '--vm-name', 'US702NTB0559', '--local-user', 'rb.jfk', '--rdp', '--debug']
cli.knack.cli: init debug log:
Enable color in terminal.
Enable VT mode.
cli.knack.cli: Event: Cli.PreExecute []
cli.knack.cli: Event: CommandParser.OnGlobalArgumentsCreate [<function CLILogging.on_global_arguments at 0x00000202568C0900>, <function OutputProducer.on_global_arguments at 0x00000202571504A0>, <function CLIQuery.on_global_arguments at 0x000002025717D8A0>]
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate []
cli.azure.cli.core: No module found from index for '['ssh', 'arc', '--resource-group', 'oec-east2-dev-it-internal-rg', '--vm-name', 'US702NTB0559', '--local-user', 'rb.jfk', '--rdp', '--debug']'
cli.azure.cli.core: Loading all modules and extensions
cli.azure.cli.core: Discovered command modules: ['acr', 'acs', 'advisor', 'ams', 'apim', 'appconfig', 'appservice', 'aro', 'backup', 'batch', 'batchai', 'billing', 'botservice', 'cdn', 'cloud', 'cognitiveservices', 'compute_recommender', 'computefleet', 'config', 'configure', 'consumption', 'container', 'containerapp', 'cosmosdb', 'databoxedge', 'dls', 'dms', 'eventgrid', 'eventhubs', 'extension', 'feedback', 'find', 'hdinsight', 'identity', 'interactive', 'iot', 'keyvault', 'lab', 'managedservices', 'maps', 'marketplaceordering', 'monitor', 'mysql', 'netappfiles', 'network', 'policyinsights', 'privatedns', 'profile', 'rdbms', 'redis', 'relay', 'resource', 'role', 'search', 'security', 'servicebus', 'serviceconnector', 'servicefabric', 'signalr', 'sql', 'sqlvm', 'storage', 'synapse', 'util', 'vm']
cli.azure.cli.core: Loading command modules:
cli.azure.cli.core: Name Load Time Groups Commands
cli.azure.cli.core: acr 0.170 36 149
cli.azure.cli.core: acs 0.018 15 79
cli.azure.cli.core: advisor 0.002 3 6
cli.azure.cli.core: ams 0.004 22 100
cli.azure.cli.core: apim 0.006 14 69
cli.azure.cli.core: appconfig 0.002 9 47
cli.azure.cli.core: appservice 0.019 80 277
cli.azure.cli.core: aro 0.011 1 10
cli.azure.cli.core: backup 0.003 16 60
cli.azure.cli.core: batch 0.038 32 96
cli.azure.cli.core: batchai 0.003 10 30
cli.azure.cli.core: billing 0.012 19 53
cli.azure.cli.core: botservice 0.003 12 42
cli.azure.cli.core: cdn 0.122 8 50
cli.azure.cli.core: cloud 0.002 1 7
cli.azure.cli.core: cognitiveservices 0.002 10 33
cli.azure.cli.core: compute_recommender 0.003 1 1
cli.azure.cli.core: computefleet 0.007 1 1
cli.azure.cli.core: config 0.001 2 7
cli.azure.cli.core: configure 0.001 2 5
cli.azure.cli.core: consumption 0.017 8 9
cli.azure.cli.core: container 0.007 2 17
cli.azure.cli.core: containerapp 0.093 37 123
cli.azure.cli.core: cosmosdb 0.010 58 200
cli.azure.cli.core: databoxedge 0.007 5 28
cli.azure.cli.core: dls 0.002 6 36
cli.azure.cli.core: dms 0.002 3 22
cli.azure.cli.core: eventgrid 0.003 25 96
cli.azure.cli.core: eventhubs 0.010 14 21
cli.azure.cli.core: extension 0.001 1 7
cli.azure.cli.core: feedback 0.001 1 2
cli.azure.cli.core: find 0.001 1 1
cli.azure.cli.core: hdinsight 0.007 9 42
cli.azure.cli.core: identity 0.006 2 7
cli.azure.cli.core: interactive 0.000 1 1
cli.azure.cli.core: iot 0.221 19 82
cli.azure.cli.core: keyvault 0.007 20 114
cli.azure.cli.core: lab 0.050 9 30
cli.azure.cli.core: managedservices 0.009 3 8
cli.azure.cli.core: maps 0.002 5 13
cli.azure.cli.core: marketplaceordering 0.003 1 2
cli.azure.cli.core: monitor 0.202 18 64
cli.azure.cli.core: mysql 0.106 16 56
cli.azure.cli.core: netappfiles 0.050 8 15
cli.azure.cli.core: network 0.059 105 350
cli.azure.cli.core: policyinsights 0.015 9 17
cli.azure.cli.core: privatedns 0.018 14 60
cli.azure.cli.core: profile 0.002 2 8
cli.azure.cli.core: rdbms 0.060 52 217
cli.azure.cli.core: redis 0.002 7 38
cli.azure.cli.core: relay 0.021 7 8
cli.azure.cli.core: resource 0.011 52 232
cli.azure.cli.core: role 0.002 17 62
cli.azure.cli.core: search 0.006 7 19
cli.azure.cli.core: security 0.009 48 98
cli.azure.cli.core: servicebus 0.007 13 17
cli.azure.cli.core: serviceconnector 0.014 20 331
cli.azure.cli.core: servicefabric 0.012 27 80
cli.azure.cli.core: signalr 0.002 10 42
cli.azure.cli.core: sql 0.010 56 215
cli.azure.cli.core: sqlvm 0.016 4 20
cli.azure.cli.core: storage 0.073 60 275
cli.azure.cli.core: synapse 0.006 54 246
cli.azure.cli.core: util 0.001 3 7
cli.azure.cli.core: vm 0.048 59 262
cli.azure.cli.core: Total (65) 1.638 1192 4722
cli.azure.cli.core: Loaded 1178 groups, 4722 commands.
cli.azure.cli.core: Updated command index in 0.002 seconds.
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate [<function AzCliLogging.init_command_file_logging at 0x000002025753B060>]
cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to 'C:\Users\rb.jfk.azure\commands\2025-06-13.16-36-07.ssh.17672.log'.
az_command_data_logger: command args: ssh {} --resource-group {} --vm-name {} --local-user {} --rdp --debug
cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [<function register_global_subscription_argument.
cli.azure.cli.core.extension.operations: Command '['C:\Program Files\Microsoft SDKs\Azure\CLI2\python.exe', '-m', 'pip', 'install', '--target', 'C:\Users\rb.jfk\.azure\cliextensions\ssh', 'C:\Users\rb.jfk\AppData\Local\Temp\tmpig9tq0z1\ssh-2.0.6-py3-none-any.whl', '--disable-pip-version-check', '--no-cache-dir']' returned non-zero exit status 2. cli.azure.cli.core.extension.operations: Pip failed so deleting anything we might have installed at C:\Users\rb.jfk.azure\cliextensions\ssh cli.azure.cli.core.azclierror: Traceback (most recent call last): File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/cli.py", line 233, in invoke File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 591, in execute File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/parser.py", line 261, in parse_args File "argparse.py", line 1904, in parse_args File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/parser.py", line 281, in parse_known_args File "argparse.py", line 1914, in parse_known_args File "argparse.py", line 1943, in _parse_known_args2 File "argparse.py", line 2165, in _parse_known_args File "argparse.py", line 2141, in consume_positionals File "argparse.py", line 2003, in take_action File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/parser.py", line 272, in _get_values File "argparse.py", line 2523, in _get_values File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/parser.py", line 300, in _check_value File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/extension/dynamic_install.py", line 132, in try_install_extension File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/extension/dynamic_install.py", line 242, in _check_value_in_extensions File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/extension/operations.py", line 343, in add_extension File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/extension/operations.py", line 172, in _add_whl_ext knack.util.CLIError: An error occurred. Pip failed with status code 2. Use --debug for more information.
cli.azure.cli.core.azclierror: An error occurred. Pip failed with status code 2. Use --debug for more information. az_command_data_logger: An error occurred. Pip failed with status code 2. Use --debug for more information. cli.knack.cli: Event: Cli.PostExecute [<function AzCliLogging.deinit_cmd_metadata_logging at 0x000002025753B2E0>] az_command_data_logger: exit code: 1 cli.main: Command ran in 16.706 seconds (init: 0.358, invoke: 16.348) 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 4020 in cache file under C:\Users\rb.jfk.azure\telemetry\20250613163622593 telemetry.main: Begin creating telemetry upload process. telemetry.process: Creating upload process: "C:\Program Files\Microsoft SDKs\Azure\CLI2\python.exe C:\Program Files\Microsoft SDKs\Azure\CLI2\Lib\site-packages\azure\cli\telemetry_init_.pyc C:\Users\rb.jfk.azure C:\Users\rb.jfk.azure\telemetry\20250613163622593" telemetry.process: Return from creating process 12304 telemetry.main: Finish creating telemetry upload process.
Expected behavior
I should be able to install the extension as a dependency & then complete running the command to RDP to the target system.
Environment Summary
azure-cli 2.74.0
core 2.74.0 telemetry 1.1.0
Dependencies: msal 1.32.3 azure-mgmt-resource 23.3.0
Python location 'C:\Program Files\Microsoft SDKs\Azure\CLI2\python.exe' Config directory 'C:\Users\rb.jfk.azure' Extensions directory 'C:\Users\rb.jfk.azure\cliextensions'
Python (Windows) 3.12.10 (tags/v3.12.10:0cc8128, Apr 8 2025, 12:21:36) [MSC v.1943 64 bit (AMD64)]
Legal docs and information: aka.ms/AzureCliLegal
Additional context
No response
Thank you for opening this issue, we will look into it.
Here are some similar issues that might help you. Please check if they can solve your problem.
- #30684
- #8315
- #29892
Possible solution (Extracted from existing issue, might be incorrect; please verify carefully)
Solution 1:
Try this command python -m pip install --upgrade pip. This will upgrade pip and you should be unblocked post that.
Reference:
- https://github.com/azure/azure-cli/issues/8315#issuecomment-457444637
Solution 2:
Confirmed that the Workaround solved the issue. I have conda installed on my machine, which was interfering with the install.
Reference:
- https://github.com/azure/azure-cli/issues/30684#issuecomment-2624064114
Powered by issue-sentinel
I'm unable to upgrade PIP. This is my output:
C:\Program Files\Microsoft SDKs\Azure\CLI2>python.exe -m pip install --upgrade pip
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: pip in c:\program files\microsoft sdks\azure\cli2\lib\site-packages (25.1.1)
ERROR: Exception:
Traceback (most recent call last):
File "C:\Program Files\Microsoft SDKs\Azure\CLI2\Lib\site-packages\pip_internal\cli\base_command.py", line 105, in _run_wrapper
status = _inner_run()
^^^^^^^^^^^^
File "C:\Program Files\Microsoft SDKs\Azure\CLI2\Lib\site-packages\pip_internal\cli\base_command.py", line 96, in _inner_run
return self.run(options, args)
^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Microsoft SDKs\Azure\CLI2\Lib\site-packages\pip_internal\cli\req_command.py", line 68, in wrapper
return func(self, options, args)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Microsoft SDKs\Azure\CLI2\Lib\site-packages\pip_internal\commands\install.py", line 387, in run
requirement_set = resolver.resolve(
^^^^^^^^^^^^^^^^^
File "C:\Program Files\Microsoft SDKs\Azure\CLI2\Lib\site-packages\pip_internal\resolution\resolvelib\resolver.py", line 96, in resolve
result = self._result = resolver.resolve(
^^^^^^^^^^^^^^^^^
File "C:\Program Files\Microsoft SDKs\Azure\CLI2\Lib\site-packages\pip_vendor\resolvelib\resolvers\resolution.py", line 515, in resolve
state = resolution.resolve(requirements, max_rounds=max_rounds)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Microsoft SDKs\Azure\CLI2\Lib\site-packages\pip_vendor\resolvelib\resolvers\resolution.py", line 388, in resolve
self._add_to_criteria(self.state.criteria, r, parent=None)
File "C:\Program Files\Microsoft SDKs\Azure\CLI2\Lib\site-packages\pip_vendor\resolvelib\resolvers\resolution.py", line 141, in _add_to_criteria
if not criterion.candidates:
^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Microsoft SDKs\Azure\CLI2\Lib\site-packages\pip_vendor\resolvelib\structs.py", line 194, in bool
return bool(self._sequence)
^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Microsoft SDKs\Azure\CLI2\Lib\site-packages\pip_internal\resolution\resolvelib\found_candidates.py", line 163, in bool
self._bool = any(self)
^^^^^^^^^
File "C:\Program Files\Microsoft SDKs\Azure\CLI2\Lib\site-packages\pip_internal\resolution\resolvelib\found_candidates.py", line 147, in
& I don't have conda installed on my machine so I don't believe the workaround would work.
Thank you for your quick responses on this!
I was hoping to hear if there was any further advice on this.
Can anyone please help on this issue? I cannot find anything on this error anywhere. I'm pretty stumped on what to do and need to get this working.
You're the first one reporting RecursionError: maximum recursion depth exceeded
What's the output of az extension add -n ssh --debug?
I am seeing the exact same issue when running AZCLI on Azure Virtual Desktop. Currently the newest version that will run is 2.65.0 both x86 and x64. We did not notice this issue until updating an AVD host pool and trying to install the latest version of the toolset.