Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The example with "localhost" and "uname" is broken #379

Open
PPPW opened this issue May 18, 2023 · 2 comments
Open

The example with "localhost" and "uname" is broken #379

PPPW opened this issue May 18, 2023 · 2 comments

Comments

@PPPW
Copy link

PPPW commented May 18, 2023

For general questions please use the mail group.

Describe the bug
The example in the README is broken:

from pssh.clients import ParallelSSHClient

hosts = ['localhost', 'localhost']
client = ParallelSSHClient(hosts)

output = client.run_command('uname')

To Reproduce
Run the above example.

Expected behavior
The above code runs successfully.

Actual behaviour
The above code got exception:

Traceback (most recent call last):
  File "/home/azureuser/.local/lib/python3.10/site-packages/pssh/clients/base/single.py", line 204, in _auth_retry
    self.auth()
  File "/home/azureuser/.local/lib/python3.10/site-packages/pssh/clients/base/single.py", line 364, in auth
    return self._identity_auth()
  File "/home/azureuser/.local/lib/python3.10/site-packages/pssh/clients/base/single.py", line 337, in _identity_auth
    raise AuthenticationError("No authentication methods succeeded")
pssh.exceptions.AuthenticationError: No authentication methods succeeded
...
pssh.exceptions.AuthenticationError: ('Authentication error while connecting to %s:%s - %s - retries %s/%s', 'localhost', 22, AuthenticationError('No authentication methods succeeded'), 3, 3)

Additional information
The issue happens when no auth is needed, e.g., SSH to localhost, or to a host without the need of -i. The ParallelSSHClient's constructor takes identity_auth=False, however with that, in /pssh/clients/base/single.py, it will try to do password auth, which also doesn't apply. This looks like a regression. Could you fix that and support uses cases that auth is not needed? Thank you!

@christiankotait
Copy link

Same issue. Can you please fix this?

@comperem
Copy link

comperem commented Jun 26, 2024

hello, agreed. I've experienced this problem for 2 years.

this post indicates there is a different way to import the ParallelSSHClient.

Trying this seems to work. It must be loading a different method (from ssh-python) that handles the key-based authentication.

So now the front-page example works on Ubuntu 22.04 with Python 3.10.12 and openssh-serve version 1:8.9p1-3ubuntu0.7 amd64

#from pssh.clients import ParallelSSHClient                 <-- not working
from pssh.clients.ssh.parallel import ParallelSSHClient   # <-- working

hosts = ['localhost', 'localhost']
client = ParallelSSHClient(hosts)

output = client.run_command('uname')
for host_output in output:
    for line in host_output.stdout:
        print(line)
    exit_code = host_output.exit_code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants