Skip to content

az ssh vm on CloudShell returns error 'Could not retrieve token from local cache.' #19048

@jamesc

Description

@jamesc

This is autogenerated. Please review and update as needed.

Describe the bug

Command Name
az ssh vm Extension Name: ssh. Version: 0.1.5.

Errors:

Could not retrieve token from local cache.

To Reproduce:

On Cloud Shell:

  • az ssh vm --ip {}

Expected Behavior

Should connect to the VM - instead gives error about token. It looks like the following env is set

AZURE_ACCESS_TOKEN_FILE=/tmp/accessTokens.json

but that file doesn't exist.

I would expect the CLI to give me some remediation steps to take to solve this.

Environment Summary

Linux-5.4.0-1055-azure-x86_64-with-debian-10.2 (Cloud Shell)
Python 3.6.10
Installer: DEB

azure-cli 2.26.0 *

Extensions:
azure-devops 0.18.0
ai-examples 0.2.5
ssh 0.1.5

Additional Context

Debug Log
``bash
cli.azext_ssh.ssh_utils: Running ssh-keygen command ssh-keygen -f /tmp/aadsshcerthua16hed/id_rsa -t rsa -q -N
cli.azure.cli.core._profile: '/tmp/accessTokens.json' is not a file or doesn't exist.
adal-python: 163fca45-4f05-45c6-aa3e-3f69d3b17607 - Authority:Performing instance discovery: ...
adal-python: 163fca45-4f05-45c6-aa3e-3f69d3b17607 - Authority:Performing static instance discovery
adal-python: 163fca45-4f05-45c6-aa3e-3f69d3b17607 - Authority:Authority validated via static instance discovery
adal-python: 163fca45-4f05-45c6-aa3e-3f69d3b17607 - TokenRequest:Getting token from cache with refresh if necessary.
adal-python: 163fca45-4f05-45c6-aa3e-3f69d3b17607 - CacheDriver:finding with query keys: {'_clientId': '...', 'userId': '...'}
adal-python: 163fca45-4f05-45c6-aa3e-3f69d3b17607 - CacheDriver:Looking for potential cache entries: {'_clientId': '...', 'userId': '...'}
adal-python: 163fca45-4f05-45c6-aa3e-3f69d3b17607 - CacheDriver:Found 0 potential entries.
cli.azure.cli.core.util: azure.cli.core.util.handle_exception is called with an exception:
cli.azure.cli.core.util: Traceback (most recent call last):
File "/opt/az/lib/python3.6/site-packages/knack/cli.py", line 231, in invoke
cmd_result = self.invocation.execute(args)
File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/init.py", line 657, in execute
raise ex
File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/init.py", line 720, in _run_jobs_serially
results.append(self._run_job(expanded_arg, cmd_copy))
File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/init.py", line 691, in _run_job
result = cmd_copy(params)
File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/init.py", line 328, in call
return self.handler(*args, **kwargs)
File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler
return op(**command_args)
File "/opt/az/lib/python3.6/site-packages/azure-cli-extensions/ssh/azext_ssh/custom.py", line 22, in ssh_vm
public_key_file, private_key_file, use_private_ip, ssh_utils.start_ssh_connection)
File "/opt/az/lib/python3.6/site-packages/azure-cli-extensions/ssh/azext_ssh/custom.py", line 48, in _do_ssh_op
cert_file, username = _get_and_write_certificate(cmd, public_key_file, None)
File "/opt/az/lib/python3.6/site-packages/azure-cli-extensions/ssh/azext_ssh/custom.py", line 58, in _get_and_write_certificate
_, certificate = profile.get_msal_token(scopes, data)
File "/opt/az/lib/python3.6/site-packages/azure/cli/core/_profile.py", line 637, in get_msal_token
username_or_sp_id, account[_TENANT_ID], resource)
File "/opt/az/lib/python3.6/site-packages/azure/cli/core/_profile.py", line 1107, in retrieve_token_for_user
" Please run 'az login'." if not in_cloud_console() else ''))
knack.util.CLIError: Could not retrieve token from local cache.

cli.azure.cli.core.azclierror: Could not retrieve token from local cache.
az_command_data_logger: Could not retrieve token from local cache.
cli.knack.cli: Event: Cli.PostExecute [<function AzCliLogging.deinit_cmd_metadata_logging at 0x7f63e8c73268>]
az_command_data_logger: exit code: 1
cli.main: Command ran in 0.489 seconds (init: 0.106, invoke: 0.383)
telemetry.save: Save telemetry record of length 3131 in cache

Metadata

Metadata

Assignees

Labels

VM SSHbugThis issue requires a change to an existing behavior in the product in order to be resolved.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions