# Buggy code
def _connect_proxy(
    self,
    proxy_host,
    proxy_port,
    proxy_pkey,
    user=None,
    password=None,
    num_retries=DEFAULT_RETRIES,
    retry_delay=RETRY_DELAY,
    allow_agent=True,
    timeout=None,
    forward_ssh_agent=False,
    keepalive_seconds=60,
    identity_auth=True,
):
    assert isinstance(self.port, int)
    try:
        self._proxy_client = SSHClient(
            proxy_host,
            port=proxy_port,
            pkey=proxy_pkey,
            num_retries=num_retries,
            user=user,
            password=password,
            retry_delay=retry_delay,
            allow_agent=allow_agent,
            timeout=timeout,
            forward_ssh_agent=forward_ssh_agent,
            identity_auth=identity_auth,
            keepalive_seconds=keepalive_seconds,
            _auth_thread_pool=False,
        )
    except Exception as ex:
        msg = "Proxy authentication failed. Exception from tunnel client: %s"
        logger.error(msg, ex)
        raise ProxyError(msg, ex)
    if not FORWARDER.started.is_set():
        FORWARDER.start()
        FORWARDER.started.wait()
    FORWARDER.in_q.put((self._proxy_client, self.host, self.port))
    proxy_local_port = FORWARDER.out_q.get()
    return proxy_local_port


# Traceback (pssh.exceptions.AuthenticationException)
(coba2) debian@debian-mon:~/coba2$ ssh root@10.90.200.55 -p 3322
Last login: Fri Sep 18 10:23:25 2020 from 10.90.200.57
[root@candibinangun ~]# exit
logout
Connection to 10.90.200.55 closed.

(coba2) debian@debian-mon:~/coba2$ python
Python 3.8.5 (default, Aug 28 2020, 06:44:01)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
from pssh.clients import SSHClient
sshObj=SSHClient('10.90.200.55', user='root', port=3322, num_retries=3, retry_delay=5, timeout=5)
Traceback (most recent call last):
File "/home/debian/.local/share/virtualenvs/coba2-gQE_YhKQ/lib/python3.8/site-packages/pssh/clients/base/single.py", line 93, in _auth_retry
self.auth()
File "/home/debian/.local/share/virtualenvs/coba2-gQE_YhKQ/lib/python3.8/site-packages/pssh/clients/native/single.py", line 179, in auth
self._identity_auth()
File "/home/debian/.local/share/virtualenvs/coba2-gQE_YhKQ/lib/python3.8/site-packages/pssh/clients/base/single.py", line 183, 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/debian/.local/share/virtualenvs/coba2-gQE_YhKQ/lib/python3.8/site-packages/pssh/clients/base/single.py", line 93, in _auth_retry
self.auth()
File "/home/debian/.local/share/virtualenvs/coba2-gQE_YhKQ/lib/python3.8/site-packages/pssh/clients/native/single.py", line 179, in auth
self._identity_auth()
File "/home/debian/.local/share/virtualenvs/coba2-gQE_YhKQ/lib/python3.8/site-packages/pssh/clients/base/single.py", line 183, 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/debian/.local/share/virtualenvs/coba2-gQE_YhKQ/lib/python3.8/site-packages/pssh/clients/base/single.py", line 93, in _auth_retry
self.auth()
File "/home/debian/.local/share/virtualenvs/coba2-gQE_YhKQ/lib/python3.8/site-packages/pssh/clients/native/single.py", line 179, in auth
self._identity_auth()
File "/home/debian/.local/share/virtualenvs/coba2-gQE_YhKQ/lib/python3.8/site-packages/pssh/clients/base/single.py", line 183, 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 "<stdin>", line 1, in <module>
File "/home/debian/.local/share/virtualenvs/coba2-gQE_YhKQ/lib/python3.8/site-packages/pssh/clients/native/single.py", line 103, in __init__
super(SSHClient, self).__init__(
File "/home/debian/.local/share/virtualenvs/coba2-gQE_YhKQ/lib/python3.8/site-packages/pssh/clients/base/single.py", line 80, in __init__
self._init()
File "/home/debian/.local/share/virtualenvs/coba2-gQE_YhKQ/lib/python3.8/site-packages/pssh/clients/base/single.py", line 85, in _init
self._auth_retry()
File "/home/debian/.local/share/virtualenvs/coba2-gQE_YhKQ/lib/python3.8/site-packages/pssh/clients/base/single.py", line 97, in _auth_retry
return self._auth_retry(retries=retries+1)
File "/home/debian/.local/share/virtualenvs/coba2-gQE_YhKQ/lib/python3.8/site-packages/pssh/clients/base/single.py", line 97, in _auth_retry
return self._auth_retry(retries=retries+1)
File "/home/debian/.local/share/virtualenvs/coba2-gQE_YhKQ/lib/python3.8/site-packages/pssh/clients/base/single.py", line 99, in _auth_retry
raise AuthenticationException(msg, self.host, self.port, ex)
pssh.exceptions.AuthenticationException: ('Authentication error while connecting to %s:%s - %s', '10.90.200.55', 3322, AuthenticationException('No authentication methods succeeded'))

# Fixed code
def _connect_proxy(
    self,
    proxy_host,
    proxy_port,
    proxy_pkey,
    user=None,
    password=None,
    num_retries=DEFAULT_RETRIES,
    retry_delay=RETRY_DELAY,
    allow_agent=True,
    timeout=None,
    forward_ssh_agent=False,
    keepalive_seconds=60,
    identity_auth=True,
):
    assert isinstance(self.port, int)
    try:
        self._proxy_client = SSHClient(
            proxy_host,
            port=proxy_port,
            pkey=proxy_pkey,
            num_retries=num_retries,
            user=user,
            password=password,
            retry_delay=retry_delay,
            allow_agent=allow_agent,
            timeout=timeout,
            forward_ssh_agent=forward_ssh_agent,
            identity_auth=identity_auth,
            keepalive_seconds=keepalive_seconds,
            _auth_thread_pool=False,
        )
    except Exception as ex:
        msg = "Proxy authentication failed. Exception from tunnel client: %s"
        logger.error(msg, ex)
        raise ProxyError(msg, ex)
    if not FORWARDER.started.is_set():
        FORWARDER.start()
        FORWARDER.started.wait()
    FORWARDER.enqueue(self._proxy_client, self.host, self.port)
    proxy_local_port = FORWARDER.out_q.get()
    return proxy_local_port