Python Pysftp Error

updating the package didn't work for me, as it was already up-to-date (latest for python 2.7 at least)

Found a better aproach here.

1) You can manualy add the ssh key to the known_hosts file

ssh test.rebex.net

2) Or you can set a flag to ignore it

import pysftp
cnopts = pysftp.CnOpts()
cnopts.hostkeys = None    # disable host key checking.
with pysftp.Connection('host', username='me',private_key=private_key,
                           private_key_pass=private_key_password,
                           cnopts=cnopts) as sftp
    # do stuff here

That initial error appears to be a problem connecting with the remote server (SSHException). The second (AttributeError), is from a bug in the code that occurs when the connection fails. It is fixed in the latest version of pysftp

https://pypi.python.org/pypi/pysftp

pip install -U pysftp

is your friend.