12

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.

1 Answer 1

14

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.

1
  • Great - the first form detected the two error types. Jul 8, 2013 at 7:37

You must log in to answer this question.

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