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.


Maybe ssh-keygen -lf authorized_keys is enough.

ssh-keygen -lf authorized_keys
key_read: uudecode AAAAB3Nzaf1a8eEABBABIwAAAQEA1y8gXks+s19QFdLP3ddei
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.

|improve this answer|||||
  • 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 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.