Python Paramiko, Error: CryptographyDeprecationWarning: encode_point has been deprecated on EllipticCurvePublicNumbers and will be removed in a future version.
今天Python使用Paramiko连接远端服务器的时候遇到了如题所示的错误,具体如下所示:
1 2 3 4 5 6 |
C:\Python27\lib\site-packages\paramiko\kex_ecdh_nist.py:39: CryptographyDeprecationWarning: encode_point has been deprecated on EllipticCurvePublicNumbers and will be removed in a future version. Please use EllipticCurvePublicKey.public_bytes to obtain both compressed and uncompressed point encoding. m.add_string(self.Q_C.public_numbers().encode_point()) C:\Python27\lib\site-packages\paramiko\kex_ecdh_nist.py:96: CryptographyDeprecationWarning: Support for unsafe construction of public numbers from encoded data will be removed in a future version. Please use EllipticCurvePublicKey.from_encoded_point self.curve, Q_S_bytes C:\Python27\lib\site-packages\paramiko\kex_ecdh_nist.py:111: CryptographyDeprecationWarning: encode_point has been deprecated on EllipticCurvePublicNumbers and will be removed in a future version. Please use EllipticCurvePublicKey.public_bytes to obtain both compressed and uncompressed point encoding. hm.add_string(self.Q_C.public_numbers().encode_point()) |
发生该问题的原因是因为:
Paramiko所依赖的模块包cryptography版本过高(大于2.4.2)
因为2.4.2以上的版本(不包含2.4.2)弃用了一些Paramiko需要用到的方法。
因此,解决该问题的方法是,将项目中的cryptography先卸载,然后再安装指定版本2.4.2的cryptography,即可解决。
或者,对应版本如下:
paramiko=2.6.0
cryptography=2.8
————
这样,也不会出现上面的问题。