X Tutup
The Wayback Machine - https://web.archive.org/web/20200917224630/https://github.com/ParallelSSH/parallel-ssh/issues/155
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

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

Open
Rahul-RB opened this issue Feb 12, 2019 · 27 comments
Open

Comments

@Rahul-RB
Copy link

@Rahul-RB Rahul-RB commented Feb 12, 2019

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
@Rahul-RB Rahul-RB changed the title Native Parallel Client doesn't connect to host while Paramiko based Parallel Client does Native Parallel Client doesn't connect to hosts while Paramiko based Parallel Client does Feb 12, 2019
@pkittenis pkittenis changed the title Native Parallel Client doesn't connect to hosts while Paramiko based Parallel Client does Native Parallel Client doesn't connect to hosts with password Feb 12, 2019
@pkittenis pkittenis added the bug label Feb 12, 2019
@pkittenis pkittenis changed the title Native Parallel Client doesn't connect to hosts with password Native Parallel Client doesn't connect to hosts with password on Python3 Feb 12, 2019
@pkittenis pkittenis removed the bug label Feb 13, 2019
@pkittenis
Copy link
Member

@pkittenis pkittenis commented Feb 14, 2019

Hi there,

Thanks for the interest and report. Let's not mix in #141 - the OP has not responded and there is no guarantee it is same issue.

It is not uncommon for the two clients to have different behaviour - they use different libraries. If paramiko works for you as a work around then great, but it is deprecated and pending removal. I don't think this is related to password auth, or python version, hence bug label removal.

It is more likely the server is using a host key the library does not support. Should be able to confirm by looking at server logs when the native client connects. If you can also post server config to reproduce this with, that would be useful. Without being able to reproduce there is nothing to be done.

@Rahul-RB
Copy link
Author

@Rahul-RB Rahul-RB commented Feb 14, 2019

Hi!
Thanks for the reply.

Can you please tell me what server configs will be helpful?

@pkittenis
Copy link
Member

@pkittenis pkittenis commented Feb 14, 2019

Contents of /etc/ssh/sshd_config please. Also would be good to check if public key auth works.

@Rahul-RB
Copy link
Author

@Rahul-RB Rahul-RB commented Feb 15, 2019

  • Please find attached the sshd_config of the host facing issues. (I can confirm that both the hosts (ip1 and ip2 in my issue) facing issues have same config).

  • Also, public key auth works as intended. (I followed these steps to check that, please do mention if that was the right check to do).

sshd_config.txt

@pkittenis
Copy link
Member

@pkittenis pkittenis commented Feb 21, 2019

Unable to replicate so far - both password=<..> and host_config with password entries work as expected. Will try with the above server cfg - it does not seem to use unsupported server keys at first glance.

Might be worth seeing if there is anything logged by the SSH server on the unsuccessful attempts. Usually this is in /var/log/auth.log.

@spctm
Copy link

@spctm spctm commented Feb 21, 2019

I can confirm the same issue when connecting to ESXi hosts. None of my Ubuntu hosts have problems connecting to when using native client. Its easy to repro if you have any VMware ESXi 6.0 hosts. While using paramiko client works fine. The problem is I would like to use the native client exclusively since the paramiko client will be removed in the future.

~# python3 test_pssh.py
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/pssh/clients/native/single.py", line 277, in auth
self._identity_auth()
File "/usr/local/lib/python3.6/dist-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 "/usr/local/lib/python3.6/dist-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 "/usr/local/lib/python3.6/dist-packages/pssh/clients/native/single.py", line 192, in _init
self.auth()
File "/usr/local/lib/python3.6/dist-packages/pssh/clients/native/single.py", line 282, in auth
self._password_auth()
File "/usr/local/lib/python3.6/dist-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 "/usr/local/lib/python3.6/dist-packages/pssh/clients/native/single.py", line 277, in auth
self._identity_auth()
File "/usr/local/lib/python3.6/dist-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 "/usr/local/lib/python3.6/dist-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 "/usr/local/lib/python3.6/dist-packages/pssh/clients/native/single.py", line 192, in _init
self.auth()
File "/usr/local/lib/python3.6/dist-packages/pssh/clients/native/single.py", line 282, in auth
self._password_auth()
File "/usr/local/lib/python3.6/dist-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 "/usr/local/lib/python3.6/dist-packages/pssh/clients/native/single.py", line 277, in auth
self._identity_auth()
File "/usr/local/lib/python3.6/dist-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 "/usr/local/lib/python3.6/dist-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 "/usr/local/lib/python3.6/dist-packages/pssh/clients/native/single.py", line 192, in _init
self.auth()
File "/usr/local/lib/python3.6/dist-packages/pssh/clients/native/single.py", line 282, in auth
self._password_auth()
File "/usr/local/lib/python3.6/dist-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 "test_pssh.py", line 14, in
output = client.run_command('uname -a')
File "/usr/local/lib/python3.6/dist-packages/pssh/clients/native/parallel.py", line 223, in run_command
greenlet_timeout=greenlet_timeout)
File "/usr/local/lib/python3.6/dist-packages/pssh/clients/base_pssh.py", line 96, in run_command
self.get_output(cmd, output, timeout=greenlet_timeout)
File "/usr/local/lib/python3.6/dist-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 "/usr/local/lib/python3.6/dist-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 "/usr/local/lib/python3.6/dist-packages/pssh/clients/native/parallel.py", line 237, in _run_command
raise ex
File "/usr/local/lib/python3.6/dist-packages/pssh/clients/native/parallel.py", line 230, in _run_command
self._make_ssh_client(host)
File "/usr/local/lib/python3.6/dist-packages/pssh/clients/native/parallel.py", line 387, in _make_ssh_client
keepalive_seconds=self.keepalive_seconds)
File "/usr/local/lib/python3.6/dist-packages/pssh/clients/native/single.py", line 132, in init
THREAD_POOL.apply(self._init)
File "/usr/local/lib/python3.6/dist-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 "/usr/local/lib/python3.6/dist-packages/gevent/_compat.py", line 47, in reraise
raise value.with_traceback(tb)
File "/usr/local/lib/python3.6/dist-packages/gevent/threadpool.py", line 281, in _worker
value = func(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/pssh/clients/native/single.py", line 195, in _init
return self._connect_init_retry(retries)
File "/usr/local/lib/python3.6/dist-packages/pssh/clients/native/single.py", line 174, in _connect_init_retry
return self._init(retries=retries)
File "/usr/local/lib/python3.6/dist-packages/pssh/clients/native/single.py", line 195, in _init
return self._connect_init_retry(retries)
File "/usr/local/lib/python3.6/dist-packages/pssh/clients/native/single.py", line 174, in _connect_init_retry
return self._init(retries=retries)
File "/usr/local/lib/python3.6/dist-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', '10.104.32.233', 22, AuthenticationException('Password authentication failed',))

@spctm
Copy link

@spctm spctm commented Feb 21, 2019

I haven't tried with python2 so I cannot comment on whether this problem is exclusively with python3. I debugged a little further but I can conclude that the password is being passed correctly to native client. In spite of this I get an authentication failed error, which cannot be right.

@Rahul-RB
Copy link
Author

@Rahul-RB Rahul-RB commented Feb 22, 2019

Hi @pkittenis , please find attached the auth.log file which has the lines only for the connection I tried via PSSH Native client., (I did tail-f and ensured the request times matched the times in log file).

Also, can confirm with @spctm , the VMs I'm connecting to are on VMWare ESXi 6.7.0.
Also, the VMs itself are running FreeBSD 8 64-bit.

Please do let me now if there's any other information required since ESXi is a licensed product.

auth.log

@Rahul-RB
Copy link
Author

@Rahul-RB Rahul-RB commented Feb 22, 2019

Unable to replicate so far - both password=<..> and host_config with password entries work as expected. Will try with the above server cfg - it does not seem to use unsupported server keys at first glance.

Might be worth seeing if there is anything logged by the SSH server on the unsuccessful attempts. Usually this is in /var/log/auth.log.

@pkittenis , if it's any help, the latest Paramiko Client throws these warnings when trying to connect:

/home/rahulrb/.virtualenvs/test/lib/python3.6/site-packages/paramiko/ecdsakey.py:164: CryptographyDeprecationWarning: Support for unsafe construction of public numbers from encoded data will be removed in a future version. Please use EllipticCurvePublicKey.from_encoded_point
  self.ecdsa_curve.curve_class(), pointinfo
/home/rahulrb/.virtualenvs/test/lib/python3.6/site-packages/paramiko/kex_ecdh_nist.py:39: CryptographyDeprecationWarning: encode_point has been deprecated on EllipticCurvePublicNumbers and will be removed in a future version. Please use EllipticCurvePublicKey.public_bytes to obtain both compressed and uncompressed point encoding.
  m.add_string(self.Q_C.public_numbers().encode_point())
/home/rahulrb/.virtualenvs/test/lib/python3.6/site-packages/paramiko/kex_ecdh_nist.py:96: CryptographyDeprecationWarning: Support for unsafe construction of public numbers from encoded data will be removed in a future version. Please use EllipticCurvePublicKey.from_encoded_point
  self.curve, Q_S_bytes
/home/rahulrb/.virtualenvs/test/lib/python3.6/site-packages/paramiko/kex_ecdh_nist.py:111: CryptographyDeprecationWarning: encode_point has been deprecated on EllipticCurvePublicNumbers and will be removed in a future version. Please use EllipticCurvePublicKey.public_bytes to obtain both compressed and uncompressed point encoding.
  hm.add_string(self.Q_C.public_numbers().encode_point())

I guess the two sets of warnings are repeated since I connect to two IPs at once.

@pkittenis
Copy link
Member

@pkittenis pkittenis commented Feb 22, 2019

Thanks for the info, that is very useful. Could you also confirm the version of SSH server used - sshd --version? Will try to replicate with a FreeBSD 8 docker container.

The fact they are VMs should not matter - the protocol does not change. The above paramiko warnings do not seem relevant either.

The auth log shows it is failing in preauth, meaning password auth itself is not the issue. I suspect the hash algorithm used for password auth by the server is not supported by the version of libssh2 used - can confirm if this is the case once able to reproduce. Seem to recall FreeBSD has disabled SHA1, which might explain it.

@Rahul-RB
Copy link
Author

@Rahul-RB Rahul-RB commented Feb 22, 2019

Hi,

Sure. Though my sshd on my FreeBSD box doesn't seem to recognise --version or -v or -V or -version as valid options, I found this information from ssh -V:

OpenSSH_6.1p1, OpenSSL: 0.9.8y 5 Feb 2013
FreeBSD 8.4-RELEASE amd64

Regards.

@nealdav
Copy link

@nealdav nealdav commented Mar 2, 2019

I'm seeing the same behavior/errors as the OP when running the native client against systems with older versions of OpenSSH.


The following machines return fine (with v2.5.0 and above):

OpenSSH_7.4p1, LibreSSL 2.5.0
ProductName: Mac OS X
ProductVersion: 10.12.6

OpenSSH_7.9p1, LibreSSL 2.7.3
ProductName: Mac OS X
ProductVersion: 10.14.3


But I receive the "Password authentication failed" AuthenticationException from the systems below:

OpenSSH_6.9p1, LibreSSL 2.1.8
ProductName: Mac OS X
ProductVersion: 10.11.5

OpenSSH_6.9p1, LibreSSL 2.1.8
ProductName: Mac OS X
ProductVersion: 10.11.5

OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011
ProductName: Mac OS X
ProductVersion: 10.10.5

Not having issues when using Paramiko or ssh for any of the above.

@Rahul-RB
Copy link
Author

@Rahul-RB Rahul-RB commented Mar 2, 2019

@nealdav Are those machines running on ESXi? Because if not, then I guess it's purely a case of older OpenSSH versions not being supported.

@nealdav
Copy link

@nealdav nealdav commented Mar 2, 2019

@nealdav Are those machines running on ESXi? Because if not, then I guess it's purely a case of older OpenSSH versions not being supported.

They are not and where ssh config is concerned, they are stock machines, so older OpenSSH version support would appear to be a factor.

@nealdav
Copy link

@nealdav nealdav commented Mar 2, 2019

Confirmed that using the native client, I'm able to successfully connect using private key auth to the systems above that were failing previously. So the issue appears to be specific to password-based auth on older OpenSSH versions.

@Rahul-RB
Copy link
Author

@Rahul-RB Rahul-RB commented Mar 12, 2019

Hi @pkittenis any chance for older OpenSSH version support?

@pkittenis
Copy link
Member

@pkittenis pkittenis commented Mar 12, 2019

Haven't had a chance to test yet I'm afraid. I did find a VM image of freebsd with the above openssh version to test with. Will get to it when free time allows (not much of that these days).

If anyone has the time to help investigate, a from source build of libssh2 with debug traces enabled (ENABLE_DEBUG_LOGGING=ON cmake directive) and a debug log output of it connecting to <7.0 openssh would be most helpful. This will need a from source install of ssh2-python as well.

@Rahul-RB
Copy link
Author

@Rahul-RB Rahul-RB commented Mar 13, 2019

@pkittenis No issues. I'll try making getting the FreeBSD image used for my installation and convert it into docker image this weekend. I'll post the link if I succeed.

@pkittenis
Copy link
Member

@pkittenis pkittenis commented Mar 13, 2019

Freebsd cannot be run in docker apparently - have checked - hence the VM image which is provided by the freebsd project. VM is fine to test with.

@Rahul-RB
Copy link
Author

@Rahul-RB Rahul-RB commented Mar 14, 2019

I see. Sure, I'll try obtaining a VM image of my current system and figure out a way to give a downloadable link.

@pkittenis
Copy link
Member

@pkittenis pkittenis commented Mar 15, 2019

@comperem
Copy link

@comperem comperem commented May 3, 2019

I'm getting the same error as well with Python 3.6.0 built from source on a Raspberry Pi with Stretch, so it's Raspbian 9 which is Debian based.

ssh keys are configured for password-less login with the username ( pi@localhost ) being used with parallessh.

The simple example on the parallelssh front page (https://github.com/ParallelSSH/parallel-ssh) fails with this error:
raise AuthenticationException("No authentication methods succeeded") pssh.exceptions.AuthenticationException: No authentication methods succeeded
from example, the only change was:
hosts = ['localhost', 'localhost']

ssh version: OpenSSH_7.4p1 Raspbian-10+deb9u6, OpenSSL 1.0.2r 26 Feb 2019
sshd version: OpenSSH_7.4p1 Raspbian-10+deb9u6, OpenSSL 1.0.2r 26 Feb 2019

auth log indicates:

May 3 00:11:14 iceCold sshd[1686]: Received disconnect from 127.0.0.1 port 60068:11: end [preauth]
May 3 00:11:14 iceCold sshd[1686]: Disconnected from 127.0.0.1 port 60068 [preauth]
May 3 00:11:20 iceCold sshd[1689]: Received disconnect from 127.0.0.1 port 60082:11: end [preauth]
May 3 00:11:20 iceCold sshd[1689]: Disconnected from 127.0.0.1 port 60082 [preauth]
May 3 00:11:25 iceCold sshd[1695]: Connection closed by 127.0.0.1 port 60092 [preauth]
No workeeee.

What else would help???

@pkittenis pkittenis changed the title Native Parallel Client doesn't connect to hosts with password on Python3 Client password authentication does no twork on OpenSSH server versions < 7.0 May 3, 2019
@pkittenis pkittenis changed the title Client password authentication does no twork on OpenSSH server versions < 7.0 Client password authentication does not work on OpenSSH server versions < 7.0 May 3, 2019
@pkittenis
Copy link
Member

@pkittenis pkittenis commented May 3, 2019

@comperem That does not look like same issue. Issue here is password authentication with OpenSSH servers < 7.0. Yours is pub key auth with 7.4. That is integration tested and known to work. The error message is also different and is saying the pub key did not work and no other auth methods are available.

Suggest to confirm the same authentication method works with ssh binary first, then if not working only with library can raise a new issue with code to reproduce. If it does not work with ssh it will not work with the library either and that's not a code issue with library.

@comperem
Copy link

@comperem comperem commented May 3, 2019

@xjyxjy100
Copy link

@xjyxjy100 xjyxjy100 commented Aug 6, 2019

I'm also having the same exact password authentication issue on OpenSSH for Windows 8.0. p1, LibreSSL 2.6.5. I'm using Python 3.7.4.

Public/private key authentication works perfectly with both paramiko and pssh. Password authentication works with paramiko but not pssh.

Below is the cmd message after running my pssh code:

C:\Users\Administrator\Desktop\without pw>python connect-lin-pssh.py
Traceback (most recent call last):
File "C:\Python3.7.4\lib\site-packages\pssh\clients\native\single.py", line 19
2, in _init
self.auth()
File "C:\Python3.7.4\lib\site-packages\pssh\clients\native\single.py", line 27
7, in auth
self._identity_auth()
File "C:\Python3.7.4\lib\site-packages\pssh\clients\native\single.py", line 25
9, 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 "C:\Python3.7.4\lib\site-packages\pssh\clients\native\single.py", line 19
2, in _init
self.auth()
File "C:\Python3.7.4\lib\site-packages\pssh\clients\native\single.py", line 27
7, in auth
self._identity_auth()
File "C:\Python3.7.4\lib\site-packages\pssh\clients\native\single.py", line 25
9, 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 "C:\Python3.7.4\lib\site-packages\pssh\clients\native\single.py", line 19
2, in _init
self.auth()
File "C:\Python3.7.4\lib\site-packages\pssh\clients\native\single.py", line 27
7, in auth
self._identity_auth()
File "C:\Python3.7.4\lib\site-packages\pssh\clients\native\single.py", line 25
9, 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 "connect-lin-pssh.py", line 46, in
client.run_command('mkdir -p ~/.ssh/')
File "C:\Python3.7.4\lib\site-packages\pssh\clients\native\parallel.py", line
223, in run_command
greenlet_timeout=greenlet_timeout)
File "C:\Python3.7.4\lib\site-packages\pssh\clients\base_pssh.py", line 96, in
run_command
self.get_output(cmd, output, timeout=greenlet_timeout)
File "C:\Python3.7.4\lib\site-packages\pssh\clients\base_pssh.py", line 141, i
n 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_e
xception
File "C:\Python3.7.4\lib\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 "C:\Python3.7.4\lib\site-packages\pssh\clients\native\parallel.py", line
237, in _run_command
raise ex
File "C:\Python3.7.4\lib\site-packages\pssh\clients\native\parallel.py", line
230, in _run_command
self._make_ssh_client(host)
File "C:\Python3.7.4\lib\site-packages\pssh\clients\native\parallel.py", line
387, in _make_ssh_client
keepalive_seconds=self.keepalive_seconds)
File "C:\Python3.7.4\lib\site-packages\pssh\clients\native\single.py", line 13
2, in init
THREAD_POOL.apply(self._init)
File "C:\Python3.7.4\lib\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_exce
ption
File "C:\Python3.7.4\lib\site-packages\gevent_compat.py", line 47, in reraise

raise value.with_traceback(tb)

File "C:\Python3.7.4\lib\site-packages\gevent\threadpool.py", line 281, in _wo
rker
value = func(*args, **kwargs)
File "C:\Python3.7.4\lib\site-packages\pssh\clients\native\single.py", line 19
5, in _init
return self._connect_init_retry(retries)
File "C:\Python3.7.4\lib\site-packages\pssh\clients\native\single.py", line 17
4, in _connect_init_retry
return self._init(retries=retries)
File "C:\Python3.7.4\lib\site-packages\pssh\clients\native\single.py", line 19
5, in _init
return self._connect_init_retry(retries)
File "C:\Python3.7.4\lib\site-packages\pssh\clients\native\single.py", line 17
4, in _connect_init_retry
return self._init(retries=retries)
File "C:\Python3.7.4\lib\site-packages\pssh\clients\native\single.py", line 19
7, in _init
raise AuthenticationException(msg, self.host, self.port, ex)
pssh.exceptions.AuthenticationException: ('Authentication error while connecting
to %s:%s - %s', '192.168.2.103', 22, AuthenticationException('No authentication
methods succeeded'))

C:\Users\Administrator\Desktop\without pw>python connect-lin-pssh.py
Traceback (most recent call last):
File "C:\Python3.7.4\lib\site-packages\pssh\clients\native\single.py", line 27
7, in auth
self._identity_auth()
File "C:\Python3.7.4\lib\site-packages\pssh\clients\native\single.py", line 25
9, 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 "C:\Python3.7.4\lib\site-packages\pssh\clients\native\single.py", line 28
6, in _password_auth
self.session.userauth_password(self.user, self.password)
File "ssh2\session.pyx", line 263, 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 "C:\Python3.7.4\lib\site-packages\pssh\clients\native\single.py", line 19
2, in _init
self.auth()
File "C:\Python3.7.4\lib\site-packages\pssh\clients\native\single.py", line 28
2, in auth
self._password_auth()
File "C:\Python3.7.4\lib\site-packages\pssh\clients\native\single.py", line 28
8, 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 "C:\Python3.7.4\lib\site-packages\pssh\clients\native\single.py", line 27
7, in auth
self._identity_auth()
File "C:\Python3.7.4\lib\site-packages\pssh\clients\native\single.py", line 25
9, 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 "C:\Python3.7.4\lib\site-packages\pssh\clients\native\single.py", line 28
6, in _password_auth
self.session.userauth_password(self.user, self.password)
File "ssh2\session.pyx", line 263, 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 "C:\Python3.7.4\lib\site-packages\pssh\clients\native\single.py", line 19
2, in _init
self.auth()
File "C:\Python3.7.4\lib\site-packages\pssh\clients\native\single.py", line 28
2, in auth
self._password_auth()
File "C:\Python3.7.4\lib\site-packages\pssh\clients\native\single.py", line 28
8, 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 "C:\Python3.7.4\lib\site-packages\pssh\clients\native\single.py", line 27
7, in auth
self._identity_auth()
File "C:\Python3.7.4\lib\site-packages\pssh\clients\native\single.py", line 25
9, 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 "C:\Python3.7.4\lib\site-packages\pssh\clients\native\single.py", line 28
6, in _password_auth
self.session.userauth_password(self.user, self.password)
File "ssh2\session.pyx", line 263, 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 "C:\Python3.7.4\lib\site-packages\pssh\clients\native\single.py", line 19
2, in _init
self.auth()
File "C:\Python3.7.4\lib\site-packages\pssh\clients\native\single.py", line 28
2, in auth
self._password_auth()
File "C:\Python3.7.4\lib\site-packages\pssh\clients\native\single.py", line 28
8, 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 "connect-lin-pssh.py", line 46, in
client.run_command('mkdir -p ~/.ssh/')
File "C:\Python3.7.4\lib\site-packages\pssh\clients\native\parallel.py", line
223, in run_command
greenlet_timeout=greenlet_timeout)
File "C:\Python3.7.4\lib\site-packages\pssh\clients\base_pssh.py", line 96, in
run_command
self.get_output(cmd, output, timeout=greenlet_timeout)
File "C:\Python3.7.4\lib\site-packages\pssh\clients\base_pssh.py", line 141, i
n 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_e
xception
File "C:\Python3.7.4\lib\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 "C:\Python3.7.4\lib\site-packages\pssh\clients\native\parallel.py", line
237, in _run_command
raise ex
File "C:\Python3.7.4\lib\site-packages\pssh\clients\native\parallel.py", line
230, in _run_command
self._make_ssh_client(host)
File "C:\Python3.7.4\lib\site-packages\pssh\clients\native\parallel.py", line
387, in _make_ssh_client
keepalive_seconds=self.keepalive_seconds)
File "C:\Python3.7.4\lib\site-packages\pssh\clients\native\single.py", line 13
2, in init
THREAD_POOL.apply(self._init)
File "C:\Python3.7.4\lib\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_exce
ption
File "C:\Python3.7.4\lib\site-packages\gevent_compat.py", line 47, in reraise

raise value.with_traceback(tb)

File "C:\Python3.7.4\lib\site-packages\gevent\threadpool.py", line 281, in _wo
rker
value = func(*args, **kwargs)
File "C:\Python3.7.4\lib\site-packages\pssh\clients\native\single.py", line 19
5, in _init
return self._connect_init_retry(retries)
File "C:\Python3.7.4\lib\site-packages\pssh\clients\native\single.py", line 17
4, in _connect_init_retry
return self._init(retries=retries)
File "C:\Python3.7.4\lib\site-packages\pssh\clients\native\single.py", line 19
5, in _init
return self._connect_init_retry(retries)
File "C:\Python3.7.4\lib\site-packages\pssh\clients\native\single.py", line 17
4, in _connect_init_retry
return self._init(retries=retries)
File "C:\Python3.7.4\lib\site-packages\pssh\clients\native\single.py", line 19
7, in _init
raise AuthenticationException(msg, self.host, self.port, ex)
pssh.exceptions.AuthenticationException: ('Authentication error while connecting
to %s:%s - %s', '192.168.2.103', 22, AuthenticationException('Password authenti
cation failed'))

I double checked ssh_config as well. Not sure why this is not working. Please advisde... Thank you.

@davidcamara
Copy link

@davidcamara davidcamara commented Feb 25, 2020

I am experiencing the same issue trying to connect to a SLES12-SP3 running OpenSSH_7.2p2 with username and password. It works fine on a different server running OpenSSH_7.4p1.
Any advice?

self.session.userauth_password(user, password)
File "ssh2/session.pyx", line 263, in ssh2.session.Session.userauth_password
File "ssh2/utils.pyx", line 131, in ssh2.utils.handle_error_codes
ssh2.exceptions.AuthenticationError

@estevopaz
Copy link

@estevopaz estevopaz commented Jul 23, 2020

Same error here:
#141 (comment)

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

Successfully merging a pull request may close this issue.

None yet
8 participants
You can’t perform that action at this time.
X Tutup