2

When I execute ssh-keygen -t rsa on my Windows and an old Mac I get a 38 line id_rsa file.

When I execute the same command on a new Mac I get a 27 line file.

Just wondering why I get different results?

Here is an example of a key generated on my older computers:

-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABlwAAAAdzc2gtcn
<redacted>
CyL+jJfbBajg0AAAAXamFtZXNkb2xkaXNzZW5AamFtZXNtYWMBAgME
-----END OPENSSH PRIVATE KEY-----

And on the newer:

-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABFwAAAAdzc2gtcn
<redacted>
eooc0bZ1A6i0/nvoSwAAABVkb2xkaXNqYUBDMDJXNjBFWEhURDgBAgME
-----END OPENSSH PRIVATE KEY-----
jd96
  • 133

1 Answers1

2

Use ssh-keygen -l -f filename to see key details.

For the "key generated on your older computer", you will get:

3072 SHA256:oOI4YwCA2Yu1qJJ7dCM2pH5f49gUbJs0Kl5kDL7KNDI old-mac@key.example (RSA)

and for the key "on the newer":

2048 SHA256:7uJvPe1MKKcfWpIGo3Mr4x5zNHZAXL3Y92C5rzZVBDs new-mac@key.example (RSA)

So the keys differ by the number of bits. OpenSSH generates 3072 bit keys since version 8.0. Older versions (since about 4.0) were generating 2048 bit keys. Though as both keys are BEGIN OPENSSH PRIVATE KEY, even the machine that generates 2048 key must have 7.8 at least.


Another difference that can be caused by different OpenSSH versions is the default key format. See a related question: What does ssh-keygen [-o] do?
Though it's not the case here, as both keys are in the "new" OPENSSH PRIVATE KEY format.