How to compute MD5 hash for a file on the remote server using paramiko

Question:

I have achieved how to download a file using SFTP and generate an MD5 hash of the downloaded file locally.

I am trying to upload a file to an SFTP Server and generate its MD5 hash when it’s on the server and then download the file and its MD5 hash from the remote server.

How can I computer the MD5 hash on the remote SFTP server?

Asked By: stack overflow

||

Answers:

Very few FTP/SFTP servers support calculation of remote file checksum.

You can try first (my) WinSCP GUI SFTP/FTP client to see if your FTP/SFTP server does. WinSCP supports many standard and non-standard APIs for checksum calculation. So if your server does support such API, WinSCP should be able to make use of it.

https://winscp.net/eng/docs/ui_properties#checksum


You wrote about FTP. I’ve covered that already in:


Though you possibly mistake SFTP and FTP. As Paramiko is an SSH/SFTP client. FTP and SFTP and two completely different protocols.

For SFTP/Paramiko, see:


If your FTP/SFTP server does not have remote file check sum calculation API, you cannot use FTP/SFTP for this. But commonly, if you have SFTP access (but not so with FTP), you also might have shell access. So you can use shell commands for the checksum calculation.

See Comparing MD5 of downloaded files against files on an SFTP server in Python

Answered By: Martin Prikryl
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.