parallel-ssh
parallel-ssh copied to clipboard
The example with "localhost" and "uname" is broken
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!
Same issue. Can you please fix this?
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