hmac-sha256, [email protected], hmac-sha2-256, [email protected], hmac-sha512, [email protected], hmac-sha2-512, [email protected]

Can someone help in ordering the above ciphers by security level?

  • Welcome to the community. Please elaborate what you mean by ordering them. Commented Apr 10 at 14:56
  • 1
    Order by security like recommended, secure, weak, insecure
    – user74320
    Commented Apr 10 at 17:33

1 Answer 1


OpenSSH should already have sorted them based on security, though it might not be the freshest ordering.

OpenSSH 9.6p1 defaults (see man ssh_config and search for MACs):

[email protected],[email protected],[email protected], [email protected],[email protected],[email protected], [email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1

However, the man page also says

algorithms that contain "-etm" calculate the MAC after encryption (encrypt-then-mac). These are considered safer and their use recommended.

This is currently refuted thanks to the Terrapin attack (see also these notes). If either the client or the server are unpatched, there's a security risk (though it is minimal as it still requires a manipulator in the middle). The recommendation there is to remove quite a few options:

# Disable ChaCha ciphers and -ETM MACs for "Terrapin" (CVE-2023-48795)
Ciphers [email protected]
MACs -*[email protected]

I otherwise follow the advice from Stribika's secure secure shell, whose last update pre-dates the Terrapin revalation. This recommends:

[email protected],[email protected],[email protected],hmac-sha2-512,hmac-sha2-256,[email protected]

Putting these together, the recommended list is very small, perhaps problematically so:

MACs hmac-sha2-512,hmac-sha2-256,[email protected]

I've compromised on that, in part because my client-side OpenSSH is patched and the only older SSH servers I connect to are behind firewalls. My list includes the encrypt-then-mac algorithms and even keeps them earlier in the preference list:

[email protected],[email protected],[email protected],hmac-sha2-512,hmac-sha2-256,[email protected]

See also my advice on SSH key selection and generation.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .