1

Are there any configs for OpenSSH server to disallow weak (e.g. <2048 bits) RSA keys? I'm aware of PubkeyAcceptedKeyTypes which can disallow specific key types, incl. ssh-rsa, as a whole.

1
  • This is an interesting question.
    – Pedro
    Mar 1, 2018 at 21:37

1 Answer 1

2

I can't see it would be run-time configurable, but you could change the compile-time definition of SSH_RSA_MINIMUM_MODULUS_SIZE in sshkey.h and recompile:

#define SSH_RSA_MINIMUM_MODULUS_SIZE    1024

to

#define SSH_RSA_MINIMUM_MODULUS_SIZE    2048

Either that, or just don't install keys that are shorter. It might be possible to scan the users' authorized_keys files for keys that are shorter than that, at least if we accept the length of the encoded key as an indicator of the length of the actual key.

The encoding for a 2048 bit RSA key seems to be 372 characters long, so something like this might match shorter keys:

grep -E 'ssh-rsa [a-zA-Z0-9+/=]{,371}( |$)' file...

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.