For an ordinary user, how would I verify that a private key file was generated using reasonably secure algorithms? In response to things like allegedly insecure ssh-keygen defaults.
As RubberStamp points out, this is covered in detail in stronger encryption for SSH keys but to summarize:
Look at the words in the first line, and the next one or two.
-----BEGIN RSA PRIVATE KEY----- Proc-Type: 4,ENCRYPTED DEK-Info: DES-EDE3-CBC,(hex) (several lines of base64) -----END RSA PRIVATE KEY-----
(or similarly with
DSA PRIVATE KEY or
EC PRIVATE KEY) is the old, bad-PBKDF format.
-----BEGIN RSA PRIVATE KEY----- # or DSA,EC (base64 immediately) -----END RSA PRIVATE KEY----- # ditto
is the old unencrypted format, which is even worse.
-----BEGIN OPENSSH PRIVATE KEY----- (several lines of base64) -----END OPENSSH PRIVATE KEY-----
is the OpenSSH-specific 'new' format, which is why it says
OPENSSH right there. However, this format doesn't directly show whether it's encrypted or not. The easiest way is to try reading it (either for an
ssh connection, or with
ssh-keygen to convert or modify it) and see if it needs a password. Alternatively, you can strip the labels and decode the base64 (conveniently,
openssl base64 -d does both of these!) and look at it:
$ openssl base64 -d <se200935.clr |od -c 0000000 o p e n s s h - k e y - v 1 \0 \0 0000020 \0 \0 004 n o n e \0 \0 \0 004 n o n e [snip rest] $ openssl base64 -d <se200935.enc |od -c 0000000 o p e n s s h - k e y - v 1 \0 \0 0000020 \0 \0 \n a e s 2 5 6 - c b c \0 \0 \0 0000040 006 b c r y p t [snip rest]