python - 使用python连接SSH时出错

标签 python windows ssh centos connect

我正在尝试使用 python 连接我在 Windows 中运行的虚拟 CentOS 机器之一。

我已经安装了 paramiko 模块来做这个。但低于错误

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()

我搜索并安装了 cryptography 2.6.1python version 3.7.1 使用 < em>PyCharm 2018.3 社区版

请告诉我我做错了什么

最佳答案

这些不是错误,这些是 paramiko 抛出的警告,他们需要更新代码以使用更多最新参数。你的代码应该仍然可以运行。最好的办法是查看是否有更新版本或向 paramiko 包的作者提出问题。

关于python - 使用python连接SSH时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55532832/

相关文章:

python - 当我在 Eclipse 中运行一个简单的 django 脚本时出现奇怪的 python 错误,而不是在控制台中发生

windows - npm install react-native-ibm-mobilefirst --save 给我错误

git - 使用备用帐户在 GitHub 上共享项目

windows - 使用 PuTTY 连接到运行 freeSSHd 的 Amazon EC2 Windows 实例

python - DJANGO 翻译 - 使用 django-datatrans 翻译包括 "slugs"在内的模型

python - PyDev 和 Django : Autocomplete not detecting Django?

python - 如何在 Windows 上从 python 获取长文件系统路径

windows - 如何在 cmd 窗口中使用 Windows dir 命令仅列出 .doc 或 .xls 文件?

hadoop - 为什么无法识别 sshd 服务?

python - python 中的客户端服务器编程?