pysftp / Paramiko中的“类型对象'EllipticCurvePublicKey'没有属性'from_encoded_point'”

时间:2019-09-28 09:56:38

标签: python ssh sftp paramiko pysftp

我正在DigitalOcean上运行Ubuntu 18.04 Droplet,需要设置它们之间的文件传输。

Pysftp / Paramiko库非常适合这项工作,但是在建立连接时遇到了麻烦。从桌面使用相同的代码进行连接可以很好地工作。

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

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

初始化连接时的错误消息是:

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'

1 个答案:

答案 0 :(得分:0)

现在升级到Paramiko的最新版本-2.6。

这很可能与以下问题相同:
 How to silence EllipticCurvePublicNumbers.encode_point CryptographyDeprecationWarning when using Paramiko in Python


强制性警告:除非您不关心安全性,否则请不要设置cnopts.hostkeys = None。有关正确的解决方案,请参见Verify host key with pysftp