Skip to content

Client password authentication does not work on OpenSSH server versions < 7.0 #155

@Rahul-RB

Description

@Rahul-RB

Bug report:

I have a remote host (say as some IP ip1). I can connect to it:

  • Via the Paramiko based Parallel Client (pssh.clients.miko.parallel.ParallelSSHClient).
    from pssh.clients.miko.parallel import ParallelSSHClient
    hostConfig = {
                            "ip1":{
                                       "user":"....",
                                       "password":"...."
                            },
                            "ip2:{
                                       "user":"....",
                                       "password":"...."}
    }
    cl = ParallelSSHClient(list(hostConfig.keys()),host_config=hostConfig)
    cl.run_command("ls")
    # I get correct output.

  • Via the regular Paramiko SSHClient also.
  • Via the linux ssh command.

But using the Native parallel client is giving errors

Steps to reproduce: (Same steps as for Paramiko parallel client code above, just replace the import)

    from pssh.clients.native.parallel import ParallelSSHClient
    hostConfig = {
                            "ip1":{
                                       "user":"....",
                                       "password":"...."
                            },
                            "ip2:{
                                       "user":"....",
                                       "password":"...."}
    }
    cl = ParallelSSHClient(list(hostConfig.keys()),host_config=hostConfig)
    cl.run_command("ls")
    # Waits a few minutes, then gives auth errors.

Expected behaviour: Give the outputs of commands.

Actual behaviour:

Gives a whole bunch of authentication errors:

Traceback (most recent call last):
  File "/home/rahulrb/.virtualenvs/test/lib/python3.6/site-packages/pssh/clients/native/single.py", line 277, in auth
    self._identity_auth()
  File "/home/rahulrb/.virtualenvs/test/lib/python3.6/site-packages/pssh/clients/native/single.py", line 259, in _identity_auth
    raise AuthenticationException("No authentication methods succeeded")
pssh.exceptions.AuthenticationException: No authentication methods succeeded

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/rahulrb/.virtualenvs/test/lib/python3.6/site-packages/pssh/clients/native/single.py", line 286, in _password_auth
    self.session.userauth_password(self.user, self.password)
  File "ssh2/session.pyx", line 266, in ssh2.session.Session.userauth_password
  File "ssh2/utils.pyx", line 131, in ssh2.utils.handle_error_codes
ssh2.exceptions.AuthenticationError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/rahulrb/.virtualenvs/test/lib/python3.6/site-packages/pssh/clients/native/single.py", line 192, in _init
    self.auth()
  File "/home/rahulrb/.virtualenvs/test/lib/python3.6/site-packages/pssh/clients/native/single.py", line 282, in auth
    self._password_auth()
  File "/home/rahulrb/.virtualenvs/test/lib/python3.6/site-packages/pssh/clients/native/single.py", line 288, in _password_auth
    raise AuthenticationException("Password authentication failed")
pssh.exceptions.AuthenticationException: Password authentication failed

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/rahulrb/.virtualenvs/test/lib/python3.6/site-packages/pssh/clients/native/single.py", line 277, in auth
    self._identity_auth()
  File "/home/rahulrb/.virtualenvs/test/lib/python3.6/site-packages/pssh/clients/native/single.py", line 259, in _identity_auth
    raise AuthenticationException("No authentication methods succeeded")
pssh.exceptions.AuthenticationException: No authentication methods succeeded

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/rahulrb/.virtualenvs/test/lib/python3.6/site-packages/pssh/clients/native/single.py", line 286, in _password_auth
    self.session.userauth_password(self.user, self.password)
  File "ssh2/session.pyx", line 266, in ssh2.session.Session.userauth_password
  File "ssh2/utils.pyx", line 131, in ssh2.utils.handle_error_codes
ssh2.exceptions.AuthenticationError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/rahulrb/.virtualenvs/test/lib/python3.6/site-packages/pssh/clients/native/single.py", line 192, in _init
    self.auth()
  File "/home/rahulrb/.virtualenvs/test/lib/python3.6/site-packages/pssh/clients/native/single.py", line 282, in auth
    self._password_auth()
  File "/home/rahulrb/.virtualenvs/test/lib/python3.6/site-packages/pssh/clients/native/single.py", line 288, in _password_auth
    raise AuthenticationException("Password authentication failed")
pssh.exceptions.AuthenticationException: Password authentication failed

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/rahulrb/.virtualenvs/test/lib/python3.6/site-packages/pssh/clients/native/single.py", line 277, in auth
    self._identity_auth()
  File "/home/rahulrb/.virtualenvs/test/lib/python3.6/site-packages/pssh/clients/native/single.py", line 259, in _identity_auth
    raise AuthenticationException("No authentication methods succeeded")
pssh.exceptions.AuthenticationException: No authentication methods succeeded

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/rahulrb/.virtualenvs/test/lib/python3.6/site-packages/pssh/clients/native/single.py", line 286, in _password_auth
    self.session.userauth_password(self.user, self.password)
  File "ssh2/session.pyx", line 266, in ssh2.session.Session.userauth_password
  File "ssh2/utils.pyx", line 131, in ssh2.utils.handle_error_codes
ssh2.exceptions.AuthenticationError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/rahulrb/.virtualenvs/test/lib/python3.6/site-packages/pssh/clients/native/single.py", line 192, in _init
    self.auth()
  File "/home/rahulrb/.virtualenvs/test/lib/python3.6/site-packages/pssh/clients/native/single.py", line 282, in auth
    self._password_auth()
  File "/home/rahulrb/.virtualenvs/test/lib/python3.6/site-packages/pssh/clients/native/single.py", line 288, in _password_auth
    raise AuthenticationException("Password authentication failed")
pssh.exceptions.AuthenticationException: Password authentication failed

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/rahulrb/.virtualenvs/test/lib/python3.6/site-packages/pssh/clients/native/parallel.py", line 223, in run_command
    greenlet_timeout=greenlet_timeout)
  File "/home/rahulrb/.virtualenvs/test/lib/python3.6/site-packages/pssh/clients/base_pssh.py", line 96, in run_command
    self.get_output(cmd, output, timeout=greenlet_timeout)
  File "/home/rahulrb/.virtualenvs/test/lib/python3.6/site-packages/pssh/clients/base_pssh.py", line 141, in get_output
    (channel, host, stdout, stderr, stdin) = cmd.get(timeout=timeout)
  File "src/gevent/greenlet.py", line 709, in gevent._greenlet.Greenlet.get
  File "src/gevent/greenlet.py", line 317, in gevent._greenlet.Greenlet._raise_exception
  File "/home/rahulrb/.virtualenvs/test/lib/python3.6/site-packages/gevent/_compat.py", line 47, in reraise
    raise value.with_traceback(tb)
  File "src/gevent/greenlet.py", line 766, in gevent._greenlet.Greenlet.run
  File "/home/rahulrb/.virtualenvs/test/lib/python3.6/site-packages/pssh/clients/native/parallel.py", line 237, in _run_command
    raise ex
  File "/home/rahulrb/.virtualenvs/test/lib/python3.6/site-packages/pssh/clients/native/parallel.py", line 230, in _run_command
    self._make_ssh_client(host)
  File "/home/rahulrb/.virtualenvs/test/lib/python3.6/site-packages/pssh/clients/native/parallel.py", line 387, in _make_ssh_client
    keepalive_seconds=self.keepalive_seconds)
  File "/home/rahulrb/.virtualenvs/test/lib/python3.6/site-packages/pssh/clients/native/single.py", line 132, in __init__
    THREAD_POOL.apply(self._init)
  File "/home/rahulrb/.virtualenvs/test/lib/python3.6/site-packages/gevent/pool.py", line 159, in apply
    return self.spawn(func, *args, **kwds).get()
  File "src/gevent/event.py", line 268, in gevent._event.AsyncResult.get
  File "src/gevent/event.py", line 296, in gevent._event.AsyncResult.get
  File "src/gevent/event.py", line 286, in gevent._event.AsyncResult.get
  File "src/gevent/event.py", line 266, in gevent._event.AsyncResult._raise_exception
  File "/home/rahulrb/.virtualenvs/test/lib/python3.6/site-packages/gevent/_compat.py", line 47, in reraise
    raise value.with_traceback(tb)
  File "/home/rahulrb/.virtualenvs/test/lib/python3.6/site-packages/gevent/threadpool.py", line 281, in _worker
    value = func(*args, **kwargs)
  File "/home/rahulrb/.virtualenvs/test/lib/python3.6/site-packages/pssh/clients/native/single.py", line 195, in _init
    return self._connect_init_retry(retries)
  File "/home/rahulrb/.virtualenvs/test/lib/python3.6/site-packages/pssh/clients/native/single.py", line 174, in _connect_init_retry
    return self._init(retries=retries)
  File "/home/rahulrb/.virtualenvs/test/lib/python3.6/site-packages/pssh/clients/native/single.py", line 195, in _init
    return self._connect_init_retry(retries)
  File "/home/rahulrb/.virtualenvs/test/lib/python3.6/site-packages/pssh/clients/native/single.py", line 174, in _connect_init_retry
    return self._init(retries=retries)
  File "/home/rahulrb/.virtualenvs/test/lib/python3.6/site-packages/pssh/clients/native/single.py", line 197, in _init
    raise AuthenticationException(msg, self.host, self.port, ex)
pssh.exceptions.AuthenticationException: ('Authentication error while connecting to %s:%s - %s', '<ip1>', 22, AuthenticationException('Password authentication failed',))

Additional info:

  • pssh version 1.9.1
  • ssh2_python version 0.17.0
  • paramiko version 2.4.2

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions