question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`az ssh vm` failure

See original GitHub issue

Describe the bug az ssh vm command fails with the following error.

cli.azext_ssh.ssh_utils: __init__() got an unexpected keyword argument 'text'
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 "/home/bastion/.azure/cliextensions/ssh/azext_ssh/ssh_utils.py", line 65, in start_ssh_connection
    connection_status = subprocess.run(command, env=env, text=True)
  File "/usr/lib64/python3.6/subprocess.py", line 423, in run
    with Popen(*popenargs, **kwargs) as process:
TypeError: __init__() got an unexpected keyword argument 'text'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib64/az/lib/python3.6/site-packages/knack/cli.py", line 231, in invoke
    cmd_result = self.invocation.execute(args)
  File "/usr/lib64/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 658, in execute
    raise ex
  File "/usr/lib64/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 721, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
  File "/usr/lib64/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 692, in _run_job
    result = cmd_copy(params)
  File "/usr/lib64/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 328, in __call__
    return self.handler(*args, **kwargs)
  File "/usr/lib64/az/lib/python3.6/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler
    return op(**command_args)
  File "/home/bastion/.azure/cliextensions/ssh/azext_ssh/custom.py", line 57, in ssh_vm
    _do_ssh_op(cmd, ssh_session, op_call)
  File "/home/bastion/.azure/cliextensions/ssh/azext_ssh/custom.py", line 191, in _do_ssh_op
    op_call(op_info, delete_keys, delete_cert)
  File "/home/bastion/.azure/cliextensions/ssh/azext_ssh/ssh_utils.py", line 70, in start_ssh_connection
    const.RECOMMENDATION_SSH_CLIENT_NOT_FOUND)
azure.cli.core.azclierror.BadRequestError: Failed to run ssh command with error: __init__() got an unexpected keyword argument 'text'.

cli.azure.cli.core.azclierror: Failed to run ssh command with error: __init__() got an unexpected keyword argument 'text'.
az_command_data_logger: Failed to run ssh command with error: __init__() got an unexpected keyword argument 'text'.
Ensure OpenSSH is installed and the PATH Environment Variable is set correctly.
Alternatively, use --ssh-client-folder to provide OpenSSH folder path.

To Reproduce

Expected behaviour The command should initiate the SSH connection. If it fails it should display a helpful debug message. The message Ensure OpenSSH is installed and the PATH Environment Variable is set correctly. is misleading as ssh is accessible via the path and OpenSSH is updated to latest stable version;

Environment summary OS: centos 7

azure-cli                         2.35.0

core                              2.35.0
telemetry                          1.0.6

Extensions:
ssh                                1.1.0

Dependencies:
msal                              1.17.0
azure-mgmt-resource               20.0.0

Python location '/usr/bin/python3.6'
Extensions directory '/home/bastion/.azure/cliextensions'

Python (Linux) 3.6.8 (default, Nov 16 2020, 16:55:22) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-44)]

Legal docs and information: aka.ms/AzureCliLegal


Your CLI is up-to-date.

Please let us know how we are doing: https://aka.ms/azureclihats
and let us know if you're interested in trying out our newest features: https://aka.ms/CLIUXstudy

Additional context The behaviour is not consistent as the same plugin works flawlessly on other systems.

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
lbergeron01commented, Apr 22, 2022

The new code of extension v1.1.0 is not able to translate C:\Windows\System32\OpenSsh to c:\windows\sysnative\openssh.

You can either :

  • specify flag --ssh-client-folder with c:\windows\sysnative\openssh
  • set c:\windows\sysnative\openssh to the PATH environment variable.

This is what fixed it for us.

1reaction
lbergeron01commented, Apr 22, 2022

@navba-MSFT which path did you add to your PATH environment variable? We are facing the same issue, and C:\Windows\System32\OpenSSH is in our PATH, and we are still receiving the error message.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Detailed SSH troubleshooting for an Azure VM - Microsoft Learn
The SSH client on your computer might fail to connect to the SSH service on the Azure VM due to issues or misconfigurations...
Read more >
Cannot SSH to Azure VM - Stack Overflow
Looks to be an issue with the local firewall. Try resetting the SSH configuration in the portal. Go to Azure Portal; Select VM...
Read more >
Azure Linux VM SSH Error - Permission denied (publickey)
When you are working with Linux VMs (IaaS) in Azure, the most common way to access the VM is through Secure Shell (SSH)....
Read more >
Azure AD SSH Login Issues - Reddit
When I run the "az ssh vm -n -g "… ... It never actually connects to the VM and gives no error. ......
Read more >
SSH into the VM using PuTTY - SFTP Gateway Support ·
To connect to your Linux VM over SSH from Windows, you can use PuTTY. A common way to SSH into Linux is to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found