0

As part of my job I often find myself transferring lots of files between my computer and a remote storage space accessible over SFTP. To ensure the files' correct transfer I compute their SHA256 hashes prior to transferring them, transfer them, then verify these hashes on my computer. However, this can be very lengthy since I often download several gigabytes on my computer from the remote storage.

Now, I have been curious about forcing SCP to use HMAC-RIPEMD160 to ensure message integrity (-o MACs=hmac-ripemd160). It's the strongest HMAC supported by my servers, and admittedly it is weaker than SHA256, but if I rely on SSH's own mechanisms to ensure message integrity, in principle it should be enough to not have to spend a long time calculating and then verifying file hashes when transferring stuff.

So, to wrap it up: can I replace computing and verifying file hashes with using SCP with HMAC-RIPEMD160?

1

SSH establishes a secure channel between the client and the server. This means that any corruption of the file (accidental or malicious) will be detected. You do not need to do anything special! The only thing you need to do is to check that the return value of the scp or sftp command is 0, indicating success.

If scp or sftp indicates success, then the file has been transferred successfully. Any verification you might do by a hash computation would be redundant.

The MACs option controls which MAC SSH uses as part of its secure channel protocol. It is extremely rare to need to change that setting: the client and the server will negotiate an algorithm that they both support.

To wrap it up: you can replace computing and verifying the hashes by verifying the return status of scp or sftp.

0

Let's see what the manpage says:

 MACs    Specifies the MAC (message authentication code) algorithms in
         order of preference.  The MAC algorithm is used in protocol ver-
         sion 2 for data integrity protection.  Multiple algorithms must
         be comma-separated.  The default is:

               hmac-md5,hmac-sha1,umac-64@openssh.com,
               hmac-ripemd160,hmac-sha1-96,hmac-md5-96,
               hmac-sha2-256,hmac-sha2-512

So, something like this should verify the data hasn't been changed when copied:

scp -2 -o MACs=hmac-ripemd160 set@host.example.com:some.file .

In terms of cryptographic strength, ripemd160 is one of the few 1990s cryptographic hashes that is still safe. (Wikipedia incorrectly claims it is vulnerable to an attack with a complexity of 2^51, but it's actually only a weakened ripemd160 variant that is vulnerable)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.