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

Connection dies with EOF in transport thread and raises an AuthenticationException #1098

Open
Manzabar opened this issue Oct 20, 2017 · 5 comments

Comments

@Manzabar
Copy link

I've written a Python+Paramiko script that I use at work to automate transferring files back and forth between a number of different servers; both within my organization and outside it. Recently one of our internal servers (running HP-UX) got updated from OpenSSL 0.9.8y to OpenSSL 1.0.2h. Since that happened, my script is dieing with EOF in transport thread and throwing an AuthenticationException.

I'm looking for any suggestions on what to try to do to troubleshoot/fix this issue.

Notes

  • The computer running the script is a Windows box, which currently has:
    -- Python 2.7.13
    -- Paramiko 2.3.1
  • The server I'm having problems connecting to is HP-UX.
  • I've tested connecting to the HP-UX using FileZilla and copied/pasted the username/password from the script. This connects without any problems.
  • Everytime I run my script, it gets to "userauth is OK" then throws the "EOF in transport thread" at me before dieing with the AuthenticationException.
  • From talking to our sysadmin of the HP-UX machine, even with higher levels of logging enabled, there's nothing useful in the server logs. To him, it looks like the connection just bombed out.
  • Below are a simplified and anonymized version of the script and the log file it generates.

Simplified Test Connect Script

import os
import traceback
import logging
import paramiko
__scriptname__ = 'TEST_SFTP_CONNECT'
SFTP_CONFIG = {
    'host' : 'servername.domain.org',
    'port' : 22,
    'user' : 'username_withheld',
    'pswd' : 'nope_this_isnt_a_real_pswd',
    'path' : '/path/to/files/'
    }
LOGLEVEL = 'DEBUG'
LOGNAME = os.path.join(r'C:\Python27\', __scriptname__ + '.log')
logging.basicConfig(filename=LOGNAME
                        , filemode='a'
                        , format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s'
                        , datefmt='%Y-%m-%d %H:%M'
                        , level=LOGLEVEL)
logger = logging.getLogger()
logger.info('Starting the "' + __scriptname__ + ' script.')
try:
    logger.info('Preparing to download files.')
    ssh = paramiko.SSHClient()
    logger.info('Connecting to ' + SFTP_CONFIG['host'] + ' as ' + SFTP_CONFIG['user'])
    ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
    ssh.connect(SFTP_CONFIG['host'],
            SFTP_CONFIG['port'],
                    SFTP_CONFIG['user'],
                    SFTP_CONFIG['pswd'])
    logger.debug('Opening SFTP connection.')
    sftp = ssh.open_sftp()
    sftp.chdir(SFTP_CONFIG['path'])
    logger.info('sftp.listdir()')
    logger.info(sftp.listdir())
    sftp.close()
    logger.debug('Closed SFTP connection')
except Exception as err:
    logger.error('SFTP-Down: %s', err)
    logger.error(traceback.format_exc())

Sample Log File

2017-10-19 15:27 root         INFO     Starting the "TEST_SFTP_CONNECT script.
2017-10-19 15:27 root         INFO     Preparing to download files.
2017-10-19 15:27 root         INFO     Connecting to servername.domain.org as username_withheld
2017-10-19 15:27 paramiko.transport DEBUG    starting thread (client mode): 0x2d10c30L
2017-10-19 15:27 paramiko.transport DEBUG    Local version/idstring: SSH-2.0-paramiko_2.3.1
2017-10-19 15:27 paramiko.transport DEBUG    Remote version/idstring: SSH-1.99-OpenSSH_7.3p1+sftpfilecontrol-v1.3-hpn14v11
2017-10-19 15:27 paramiko.transport INFO     Connected (version 1.99, client OpenSSH_7.3p1+sftpfilecontrol-v1.3-hpn14v11)
2017-10-19 15:27 paramiko.transport DEBUG    kex algos:[u'curve25519-sha256@libssh.org', u'ecdh-sha2-nistp256', u'ecdh-sha2-nistp384', u'ecdh-sha2-nistp521', u'diffie-hellman-group-exchange-sha256', u'diffie-hellman-group16-sha512', u'diffie-hellman-group18-sha512', u'diffie-hellman-group14-sha256', u'diffie-hellman-group14-sha1'] server key:[u'ssh-rsa', u'rsa-sha2-512', u'rsa-sha2-256', u'ecdsa-sha2-nistp256', u'ssh-ed25519'] client encrypt:[u'chacha20-poly1305@openssh.com', u'aes128-ctr', u'aes192-ctr', u'aes256-ctr', u'aes128-gcm@openssh.com', u'aes256-gcm@openssh.com'] server encrypt:[u'chacha20-poly1305@openssh.com', u'aes128-ctr', u'aes192-ctr', u'aes256-ctr', u'aes128-gcm@openssh.com', u'aes256-gcm@openssh.com'] client mac:[u'umac-64-etm@openssh.com', u'umac-128-etm@openssh.com', u'hmac-sha2-256-etm@openssh.com', u'hmac-sha2-512-etm@openssh.com', u'hmac-sha1-etm@openssh.com', u'umac-64@openssh.com', u'umac-128@openssh.com', u'hmac-sha2-256', u'hmac-sha2-512', u'hmac-sha1'] server mac:[u'umac-64-etm@openssh.com', u'umac-128-etm@openssh.com', u'hmac-sha2-256-etm@openssh.com', u'hmac-sha2-512-etm@openssh.com', u'hmac-sha1-etm@openssh.com', u'umac-64@openssh.com', u'umac-128@openssh.com', u'hmac-sha2-256', u'hmac-sha2-512', u'hmac-sha1'] client compress:[u'none', u'zlib@openssh.com'] server compress:[u'none', u'zlib@openssh.com'] client lang:[u''] server lang:[u''] kex follows?False
2017-10-19 15:27 paramiko.transport DEBUG    Kex agreed: ecdh-sha2-nistp256
2017-10-19 15:27 paramiko.transport DEBUG    HostKey agreed: ssh-ed25519
2017-10-19 15:27 paramiko.transport DEBUG    Cipher agreed: aes128-ctr
2017-10-19 15:27 paramiko.transport DEBUG    MAC agreed: hmac-sha2-256
2017-10-19 15:27 paramiko.transport DEBUG    Compression agreed: none
2017-10-19 15:27 paramiko.transport DEBUG    kex engine KexNistp256 specified hash_algo <built-in function openssl_sha256>
2017-10-19 15:27 paramiko.transport DEBUG    Switch to new keys ...
2017-10-19 15:27 paramiko.transport DEBUG    Adding ssh-ed25519 host key for servername.domain.org: 00000000000000000000000000000000
2017-10-19 15:27 paramiko.transport DEBUG    userauth is OK
2017-10-19 15:27 paramiko.transport DEBUG    EOF in transport thread
2017-10-19 15:27 root         ERROR    SFTP-Down: Authentication failed.
2017-10-19 15:27 root         ERROR    Traceback (most recent call last):
  File "TEST_SFTP_CONNECT.py", line 31, in <module>
    SFTP_CONFIG['pswd'])
  File "C:\PROGRA~1\Python27\lib\site-packages\paramiko\client.py", line 416, in connect
    look_for_keys, gss_auth, gss_kex, gss_deleg_creds, t.gss_host,
  File "C:\PROGRA~1\Python27\lib\site-packages\paramiko\client.py", line 701, in _auth
    raise saved_exception
AuthenticationException: Authentication failed.

Thanks!

@otary
Copy link

otary commented Oct 25, 2017

i also met this promble!

@ploxiln
Copy link
Contributor

ploxiln commented Oct 26, 2017

This somewhat resembles #1004 - can you try with paramiko 2.1.2?

@Manzabar
Copy link
Author

Unfortunately, that gave the same results. I uninstalled paramiko, installed paramiko-2.1.2, ran my Simplified Test Connect Script from above and got the log below:

2017-10-26 08:30 root         INFO     Starting the "TEST_SFTP_CONNECT script.
2017-10-26 08:30 root         INFO     Preparing to download files.
2017-10-26 08:30 root         INFO     Connecting to servername.domain.org as username_withheld
2017-10-26 08:30 paramiko.transport DEBUG    starting thread (client mode): 0x2c90ff0L
2017-10-26 08:30 paramiko.transport DEBUG    Local version/idstring: SSH-2.0-paramiko_2.1.2
2017-10-26 08:30 paramiko.transport DEBUG    Remote version/idstring: SSH-1.99-OpenSSH_7.3p1+sftpfilecontrol-v1.3-hpn14v11
2017-10-26 08:30 paramiko.transport INFO     Connected (version 1.99, client OpenSSH_7.3p1+sftpfilecontrol-v1.3-hpn14v11)
2017-10-26 08:30 paramiko.transport DEBUG    kex algos:[u'curve25519-sha256@libssh.org', u'ecdh-sha2-nistp256', u'ecdh-sha2-nistp384', u'ecdh-sha2-nistp521', u'diffie-hellman-group-exchange-sha256', u'diffie-hellman-group16-sha512', u'diffie-hellman-group18-sha512', u'diffie-hellman-group14-sha256', u'diffie-hellman-group14-sha1'] server key:[u'ssh-rsa', u'rsa-sha2-512', u'rsa-sha2-256', u'ecdsa-sha2-nistp256', u'ssh-ed25519'] client encrypt:[u'chacha20-poly1305@openssh.com', u'aes128-ctr', u'aes192-ctr', u'aes256-ctr', u'aes128-gcm@openssh.com', u'aes256-gcm@openssh.com'] server encrypt:[u'chacha20-poly1305@openssh.com', u'aes128-ctr', u'aes192-ctr', u'aes256-ctr', u'aes128-gcm@openssh.com', u'aes256-gcm@openssh.com'] client mac:[u'umac-64-etm@openssh.com', u'umac-128-etm@openssh.com', u'hmac-sha2-256-etm@openssh.com', u'hmac-sha2-512-etm@openssh.com', u'hmac-sha1-etm@openssh.com', u'umac-64@openssh.com', u'umac-128@openssh.com', u'hmac-sha2-256', u'hmac-sha2-512', u'hmac-sha1'] server mac:[u'umac-64-etm@openssh.com', u'umac-128-etm@openssh.com', u'hmac-sha2-256-etm@openssh.com', u'hmac-sha2-512-etm@openssh.com', u'hmac-sha1-etm@openssh.com', u'umac-64@openssh.com', u'umac-128@openssh.com', u'hmac-sha2-256', u'hmac-sha2-512', u'hmac-sha1'] client compress:[u'none', u'zlib@openssh.com'] server compress:[u'none', u'zlib@openssh.com'] client lang:[u''] server lang:[u''] kex follows?False
2017-10-26 08:30 paramiko.transport DEBUG    Kex agreed: diffie-hellman-group14-sha1
2017-10-26 08:30 paramiko.transport DEBUG    Cipher agreed: aes128-ctr
2017-10-26 08:30 paramiko.transport DEBUG    MAC agreed: hmac-sha2-256
2017-10-26 08:30 paramiko.transport DEBUG    Compression agreed: none
2017-10-26 08:30 paramiko.transport DEBUG    kex engine KexGroup14 specified hash_algo <built-in function openssl_sha1>
2017-10-26 08:30 paramiko.transport DEBUG    Switch to new keys ...
2017-10-26 08:30 paramiko.transport DEBUG    Adding ssh-rsa host key for servername.domain.org: 00000000000000000000000000000000
2017-10-26 08:30 paramiko.transport DEBUG    userauth is OK
2017-10-26 08:30 paramiko.transport DEBUG    EOF in transport thread
2017-10-26 08:30 root         ERROR    SFTP-Down: Authentication failed.
2017-10-26 08:30 root         ERROR    Traceback (most recent call last):
  File "TEST_SFTP_CONNECT.py", line 31, in <module>
    SFTP_CONFIG['pswd'])
  File "C:\PROGRA~1\Python27\lib\site-packages\paramiko\client.py", line 381, in connect
    look_for_keys, gss_auth, gss_kex, gss_deleg_creds, gss_host)
  File "C:\PROGRA~1\Python27\lib\site-packages\paramiko\client.py", line 622, in _auth
    raise saved_exception
AuthenticationException: Authentication failed.

@doneria-anjali
Copy link

doneria-anjali commented May 19, 2020

Facing the same issue when working with paramiko to connect to a Win 7 VM.
Python version: 2.7.14
Paramiko: 2.7.1

What helped you in resolution of this issue @Manzabar?

Thanks.

@Manzabar
Copy link
Author

@doneria-anjali I never was able to resolve this. The organization I was working for ended up going with a totally different solution.

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

No branches or pull requests

4 participants