Last Updated: February 25, 2016
·
3.506K
· trinitronx

Check md5sum of remote file

If you've ever found yourself in need of double checking whether files are identical across hosts, this one's for you:

(cd ${local_path_to_file} && md5sum ${file} ) | ssh ${username}@${host} "(cd ${remote_path_to_file} && md5sum -c - )"

Replace the variable placeholders to adapt to your files, host & paths you need. The last '-' is important!

It also works in the other direction, just make sure the md5sum -c - is what you're piping to.

ssh ${username}@${host} "(cd ${remote_path_to_file} && md5sum ${file} )" | (cd ${local_path_to_file} && md5sum -c - )