Azure / azure-cli-extensions

Public Repository for Extensions of Azure CLI.
https://docs.microsoft.com/en-us/cli/azure
MIT License
373 stars 1.16k forks source link

error using az ssh to linux VM using AADSSHforLinux #4068

Open rweatherly opened 2 years ago

rweatherly commented 2 years ago

This is autogenerated. Please review and update as needed.

Describe the bug

Command Name az ssh config Extension Name: ssh. Version: 0.1.8.

Errors:

The command failed with an unexpected error. Here is the traceback:
[Errno 2] No such file or directory: '/home/nclo_azu_a_t1351gw/.ssh/config'
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 29, in ssh_config
    _do_ssh_op(cmd, resource_group_name, vm_name, ssh_ip, public_key_file, private_key_file, use_private_ip, op_call)
  File "/opt/az/lib/python3.6/site-packages/azure-cli-extensions/ssh/azext_ssh/custom.py", line 50, in _do_ssh_op
    op_call(ssh_ip, username, cert_file, private_key_file)
  File "/opt/az/lib/python3.6/site-packages/azure-cli-extensions/ssh/azext_ssh/ssh_utils.py", line 81, in write_ssh_config
    with open(config_path, mode) as f:
FileNotFoundError: [Errno 2] No such file or directory: '/home/nclo_azu_a_t1351gw/.ssh/config'

To Reproduce:

Steps to reproduce the behavior. Note that argument values have been redacted, as they may contain sensitive information.

Expected Behavior

Environment Summary

Linux-5.4.0-1062-azure-x86_64-with-debian-10.2 (Cloud Shell), Common Base Linux Delridge (quinault)
Python 3.6.10
Installer: DEB

azure-cli 2.30.0

Extensions:
ai-examples 0.2.5
ssh 0.1.8

Additional Context

yonzhan commented 2 years ago

route to service team

vthiebaut10 commented 2 years ago

@rweatherly If the --file provided is in a directory that doesn't exist, the extension won't create a new directory for the config file, and the command will fail. Is that what is causing your issue?