python paramiko CryptographyDeprecationWarning

简介: import paramikoclient = paramiko.SSHClient()client.connect(serverIp, port=serverPort, username=serverUser)报警告如下:paramiko\ecdsakey.
import paramiko
client = paramiko.SSHClient()
client.connect(serverIp, port=serverPort, username=serverUser)
AI 代码解读

报警告如下:

paramiko\ecdsakey.py:164: 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.ecdsa_curve.curve_class(), pointinfo
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())
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
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())
AI 代码解读

原因

paramiko 2.4.2 依赖 cryptography,而最新的cryptography==2.5里有一些弃用的API。

解决

删掉cryptography 2.5,安装2.4.2,就不会报错了。

pip uninstall cryptography==2.5
pip install cryptography==2.4.2
AI 代码解读

补充

paramiko的issue #1369提到了这个问题,并已有PR #1379了,尚未合并。

目录
打赏
0
0
0
0
1
分享
相关文章
Python中的Paramiko与FTP文件夹及文件检测技巧
通过使用 Paramiko 和 FTP 库,开发者可以方便地检测远程服务器上的文件和文件夹是否存在。Paramiko 提供了通过 SSH 协议进行远程文件管理的能力,而 `ftplib` 则提供了通过 FTP 协议进行文件传输和管理的功能。通过理解和应用这些工具,您可以更加高效地管理和监控远程服务器上的文件系统。
55 20
python中连接linux好用的模块paramiko(附带案例)
该文章详细介绍了如何使用Python的Paramiko模块来连接Linux服务器,包括安装配置及通过密码或密钥进行身份验证的示例。
231 1
paramiko 模块 ---Python脚本监控当前系统的CPU、内存、根目录、IP地址等信息
paramiko 模块 ---Python脚本监控当前系统的CPU、内存、根目录、IP地址等信息
第十八章 Python批量管理主机(paramiko、fabric与pexpect)
第十八章 Python批量管理主机(paramiko、fabric与pexpect)
【专栏】Python 网络设备管理中,`ConnectHandler`(Paramiko库)和`telnetlib`模块常用于设备交互。
【4月更文挑战第28天】Python 网络设备管理中,`ConnectHandler`(Paramiko库)和`telnetlib`模块常用于设备交互。`ConnectHandler`简化SSH连接,便于与网络设备交互,而`telnetlib`是Python内置模块,支持Telnet协议的远程登录操作。两者都提供命令执行和响应接收功能。示例代码展示了如何使用它们获取防火墙设备的版本信息,降低了代码复杂度,提高了可读性和维护性。
244 0

热门文章

最新文章

AI助理

你好,我是AI助理

可以解答问题、推荐解决方案等