6

I've had issues copying public keys to authorized_keys and winding up with an extra linefeed or space or something.

Is there a way to simply validate that a key looks like a valid key? I don't have the private key.

7

Maybe ssh-keygen -lf authorized_keys is enough.

ssh-keygen -lf authorized_keys
key_read: uudecode AAAAB3Nzaf1a8eEABBABIwAAAQEA1y8gXks+s19QFdLP3ddei
  failed
authorized_keys is not a public key file.

(You may copy the respective line to a separate file before checking.) If the hashing function is too stupid to detect errors then converting back and forth may do:

ssh-keygen -ef id_dsa.pub -m PKCS8 | ssh-keygen -i -f /dev/stdin -m PKCS8

I expect that pipeline to fail in case of formatting errors.

  • Great - the first form detected the two error types. – Steve Bennett Jul 8 '13 at 7:37

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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