0

I'm trying to log into an SFTP site in order to pull some data. I have seen code that references a fingerprint in MD5 format (example - 52:14:a4:33:71:0a:b9:46:25:73:a0:96:94:b3:3b:03), but the key that i need to send is in a different format (I think SSH-256). When I generate a script from WinSCP to show the login info along with the RSA fingerprint I get the below:

sftp://login:password;fingerprint=ssh-rsa-ZnGWcuKoRO0Kv4uDjkdhOLHlnz9PSYfx04oGp9sE3d3=@ftp.address.com/

I've modified the actual key so it's just fictional in the post.

Can anyone please help with the Python package/code I would need to pass this type of fingerprint?

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
Don B
  • 1
  • 1
  • This is [XY problem](https://meta.stackexchange.com/q/66377/218578) - No one prevents you from getting the key in whatever format you might want. Actually with Paramiko/pysftp you typically verify the key using a full public key, not using any format of a fingerprint. – Martin Prikryl Nov 07 '19 at 21:08
  • I guess to put it another way, how can i take the information WinSCP generates about my ftp connection details, and use it in Python to connect via sftp? – Don B Nov 08 '19 at 16:39

1 Answers1

0

Your question is rather unclear. I do not understand, why you want to use information from WinSCP for your Python code.

But if you insist: There is an existing question about verifying host key in pysftp/Paramiko using MD5 fingerprint:

(I assume it's the question you refer to in your post)

In the AutoAddPolicy implementation from my answer to that question, you can replace key.get_fingerprint() with sha256(key.asbytes()).digest() to get SHA-256 fingerprint instead of MD5. You will need to import sha56 from hashlib module.


But I thing you should just follow standard Paramiko/pysftp host key verification instead, as for example shown in:

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992