我正在尝试使用python连接我在Windows中运行的一个虚拟CentOS机器。
我已经安装了paramiko模块来做tha。但低于错误
C:\Users\xxxx\PycharmProjects\xxxx\venv\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:\Users\xxx\PycharmProjects\xxxx\venv\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:\Users\xxxx\PycharmProjects\xxxx\venv\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())
以下是我的代码:
import paramiko
ssh = paramiko.client.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
try:
ssh.connect('10.xx.xx.xxx', username='root', password='xxxxx')
except paramiko.SSHException:
print("Connection Failed")
quit()
stdin, stdout, stderr = ssh.exec_command("ls /etc/")
for line in stdout.readlines():
print
line.strip()
ssh.close()
我使用PyCharm 2018.3社区版搜索并安装了加密2.6.1,python版本3.7.1。
请告诉我这里我做错了什么
这些都不是错误,这些是paramiko抛出的警告,他们需要更新代码以使用更新的参数。你的代码应该仍然运行。您最好的选择是查看是否有更新版本或提出paramiko包的作者的问题。
Paramiko使用的方法已被弃用。您应该考虑将Python降级为较低版本或下载Paramiko的更新版本(如果存在)