1

I'm running Ubuntu 18.04 droplets on DigitalOcean and need to set file transfers between them.

Pysftp/Paramiko libraries fits the job well, but I have trouble establishing connection. Connecting with same code from desktop works well.

cnopts = pysftp.CnOpts()
cnopts.hostkeys = None

with pysftp.Connection(host='ip adress',  username='username',
                       password='pass', cnopts=cnopts) as sftp:

Error message when initializing connection is:

Traceback (most recent call last):
  File "/home/airflow/airflow/tasks/ta_auto/screener_slave.py", line 315, in <module>
    cnopts = pysftp.CnOpts()#knownhosts='/home/airflow/.ssh/known_hosts')
  File "/home/airflow/pipeline/lib/python3.6/site-packages/pysftp/__init__.py", line 54, in __init__
    self.hostkeys.load(knownhosts)
  File "/home/airflow/pipeline/lib/python3.6/site-packages/paramiko/hostkeys.py", line 101, in load
    e = HostKeyEntry.from_line(line, lineno)
  File "/home/airflow/pipeline/lib/python3.6/site-packages/paramiko/hostkeys.py", line 364, in from_line
    key = ECDSAKey(data=decodebytes(key), validate_point=False)
  File "/home/airflow/pipeline/lib/python3.6/site-packages/paramiko/ecdsakey.py", line 163, in __init__
    key = ec.EllipticCurvePublicKey.from_encoded_point(
AttributeError: type object 'EllipticCurvePublicKey' has no attribute 'from_encoded_point'
Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
Martendo
  • 101
  • 2
  • 6

1 Answers1

0

Upgrade to the latest version of Paramiko – 2.6 as of now.

This is most likely the same problem as in:
How to silence EllipticCurvePublicNumbers.encode_point CryptographyDeprecationWarning when using Paramiko in Python.


Obligatory warning: Do not set cnopts.hostkeys = None, unless you do not care about security. For the correct solution see Verify host key with pysftp.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
  • Thank you, I figured it out already. Problem was causing older version of Paramiko overriding new version in my enviroment. Manual hard delete of lib files solved the problem. – Martendo Sep 30 '19 at 21:00