Running SSH in parallel

Hi, trying to run ssh in parallel to a number of hosts and reading back the reply from each one.
While trying pssh, seems that it only works with ssh-key while I have to use username and password.

The package officially support user / password, but seems to fail on Python 3.7.

Any other idea? Or how to use pssh on Python 3.x

Thanks !

Could you please post the complete error traceback of the failure?

That’s the code:

from pssh.clients import ParallelSSHClient
hosts = [‘10.0.0.204’, ‘10.0.0.205’]
client = ParallelSSHClient(hosts, user = ‘admin’, password = ‘123456’)
client.run_command(‘show run’)

Traceback (most recent call last):
File “/usr/local/lib/python3.7/dist-packages/pssh/clients/base/single.py”, line 208, in _auth_retry
self.auth()
File “/usr/local/lib/python3.7/dist-packages/pssh/clients/base/single.py”, line 355, in auth
self._password_auth()
File “/usr/local/lib/python3.7/dist-packages/pssh/clients/native/single.py”, line 229, in _password_auth
self.session.userauth_password(self.user, self.password)
File “ssh2/session.pyx”, line 321, in ssh2.session.Session.userauth_password
File “ssh2/utils.pyx”, line 166, in ssh2.utils.handle_error_codes
ssh2.exceptions.AuthenticationError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/usr/local/lib/python3.7/dist-packages/pssh/clients/base/single.py”, line 208, in _auth_retry
self.auth()
File “/usr/local/lib/python3.7/dist-packages/pssh/clients/base/single.py”, line 355, in auth
self._password_auth()
File “/usr/local/lib/python3.7/dist-packages/pssh/clients/native/single.py”, line 229, in _password_auth
self.session.userauth_password(self.user, self.password)
File “ssh2/session.pyx”, line 321, in ssh2.session.Session.userauth_password
File “ssh2/utils.pyx”, line 166, in ssh2.utils.handle_error_codes
ssh2.exceptions.AuthenticationError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/usr/local/lib/python3.7/dist-packages/pssh/clients/base/single.py”, line 208, in _auth_retry
self.auth()
File “/usr/local/lib/python3.7/dist-packages/pssh/clients/base/single.py”, line 355, in auth
self._password_auth()
File “/usr/local/lib/python3.7/dist-packages/pssh/clients/native/single.py”, line 229, in _password_auth
self.session.userauth_password(self.user, self.password)
File “ssh2/session.pyx”, line 321, in ssh2.session.Session.userauth_password
File “ssh2/utils.pyx”, line 166, in ssh2.utils.handle_error_codes
ssh2.exceptions.AuthenticationError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “”, line 1, in
File “/usr/local/lib/python3.7/dist-packages/pssh/clients/native/parallel.py”, line 217, in run_command
return_list=return_list, read_timeout=read_timeout if read_timeout else timeout,
File “/usr/local/lib/python3.7/dist-packages/pssh/clients/base/parallel.py”, line 198, in run_command
return_list=return_list)
File “/usr/local/lib/python3.7/dist-packages/pssh/clients/base/parallel.py”, line 204, in _get_output_from_cmds
finished = joinall(_cmds, raise_error=True)
File “src/gevent/greenlet.py”, line 849, in gevent._greenlet.joinall
File “src/gevent/greenlet.py”, line 865, in gevent._greenlet.joinall
File “src/gevent/greenlet.py”, line 312, in gevent._greenlet.Greenlet._raise_exception
File “/usr/lib/python3/dist-packages/gevent/_compat.py”, line 47, in reraise
raise value.with_traceback(tb)
File “src/gevent/greenlet.py”, line 716, in gevent._greenlet.Greenlet.run
File “/usr/local/lib/python3.7/dist-packages/pssh/clients/base/parallel.py”, line 216, in _get_output_from_greenlet
raise ex
File “/usr/local/lib/python3.7/dist-packages/pssh/clients/base/parallel.py”, line 209, in _get_output_from_greenlet
host_out = cmd.get()
File “src/gevent/greenlet.py”, line 633, in gevent._greenlet.Greenlet.get
File “src/gevent/greenlet.py”, line 312, in gevent._greenlet.Greenlet._raise_exception
File “/usr/lib/python3/dist-packages/gevent/_compat.py”, line 47, in reraise
raise value.with_traceback(tb)
File “src/gevent/greenlet.py”, line 716, in gevent._greenlet.Greenlet.run
File “/usr/local/lib/python3.7/dist-packages/pssh/clients/base/parallel.py”, line 285, in _run_command
raise ex
File “/usr/local/lib/python3.7/dist-packages/pssh/clients/base/parallel.py”, line 277, in _run_command
_client = self._make_ssh_client(host_i, host)
File “/usr/local/lib/python3.7/dist-packages/pssh/clients/native/parallel.py”, line 252, in _make_ssh_client
identity_auth=self.identity_auth,
File “/usr/local/lib/python3.7/dist-packages/pssh/clients/native/single.py”, line 129, in init
identity_auth=identity_auth)
File “/usr/local/lib/python3.7/dist-packages/pssh/clients/base/single.py”, line 195, in init
self._init()
File “/usr/local/lib/python3.7/dist-packages/pssh/clients/base/single.py”, line 200, in _init
self._auth_retry()
File “/usr/local/lib/python3.7/dist-packages/pssh/clients/base/single.py”, line 212, in _auth_retry
return self._auth_retry(retries=retries+1)
File “/usr/local/lib/python3.7/dist-packages/pssh/clients/base/single.py”, line 212, in _auth_retry
return self._auth_retry(retries=retries+1)
File “/usr/local/lib/python3.7/dist-packages/pssh/clients/base/single.py”, line 214, in _auth_retry
raise AuthenticationError(msg, self.host, self.port, ex)
pssh.exceptions.AuthenticationError: (‘Authentication error while connecting to %s:%s - %s’, ‘10.0.0.204’, 22, AuthenticationError())

OK, seems like the issue occurs when connecting to Arista vEOS switches.
Cisco, HP and Linux are working as expected.