azure-cli-extensions
azure-cli-extensions copied to clipboard
Illegal seek when using stdout as output file for az ssh config
Can't reproduce in a vanilla python interpreter, with the very same arguments ("/dev/stdout" and "a", and I've confirmed that both are strings at the point of execution)
Command Name
az ssh config Extension Name: ssh. Version: 0.1.5.
Errors:
The command failed with an unexpected error. Here is the traceback:
[Errno 29] Illegal seek
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 "/home/developer/.azure/cliextensions/ssh/azext_ssh/custom.py", line 28, 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 "/home/developer/.azure/cliextensions/ssh/azext_ssh/custom.py", line 49, in _do_ssh_op
op_call(ssh_ip, username, cert_file, private_key_file)
File "/home/developer/.azure/cliextensions/ssh/azext_ssh/ssh_utils.py", line 83, in write_ssh_config
with open(config_path, mode) as f:
OSError: [Errno 29] Illegal seek
To Reproduce:
Steps to reproduce the behavior. Note that argument values have been redacted, as they may contain sensitive information.
- Put any pre-requisite steps here...
-
az ssh config -f /dev/stdout -g {} -n {}
Expected Behavior
Environment Summary
Linux-5.10.60.1-microsoft-standard-WSL2-x86_64-with-debian-bullseye-sid, Ubuntu 20.04.3 LTS
Python 3.6.10
Installer: DEB
azure-cli 2.29.2 *
Extensions:
interactive 0.4.5
ssh 0.1.5
Additional Context
route to service team
@aatifsyed I can't repro this error. Here are a few things you can try:
- Make sure to use the most recent version of the extension by running "az extension update --name ssh"
- If you don't have permissions, try to run command as superuser.
- You might not be able to write generated keys in the /dev folder if you don't have permissions. Use --keys-destination-folder to help you with that. e.g. "az ssh config -g {} -n {} --keys-destination-folder ./mykeys"