Search code examples
pythonwindowssshcentos

Getting error while connecting SSH using python


I am trying to connect one of my Virtual CentOS machine running in windows using python.

i have installed paramiko module to do tha. but getting below error

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

Below is my code :

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

i searched and installed cryptography 2.6.1,python version 3.7.1 using PyCharm 2018.3 community edition.

Please let me know what i am doing wrong here


Solution

  • These are not errors, these are warnings thrown from paramiko, they need to update their code to use more up-to-date parameters. Your code should still run though. Your best bet is to see if there is an updated version or raise an issue with the authors of the paramiko package.