My Friend and I have been generating a few ssh2-rsa keys and noticed that all the public keys began with "AAAAB3NzaC1yc". The similarity extended to "AAAAB3NzaC1yc2EAAAABIwAAAQEA" between two keys I generated on the same machine on two successive attempts. I can even google "AAAAB3Nz" and end up getting a few hits.

Is this normal? Or are we doing something wrong while generating? Suffering from insufficient randomness?

  • $\begingroup$ What are you using to generate them? Openssl, openssh, pgp? It is probably an encoding. $\endgroup$ – mikeazo Jan 8 '13 at 17:39
  • $\begingroup$ We used puTTYgen on two different windows machine and ssh-keygen on a linux machine. $\endgroup$ – Lord Loh. Jan 8 '13 at 18:23

The public key blob doesn't consist of just the numbers that make up the public key: it begins with a header that says “this is an SSH public key”. The repeated prefix encodes this header.

RFC 4254 specifies the encoding of public key in SSH key format.

The "ssh-rsa" key format has the following specific encoding:

 string    "ssh-rsa"
 mpint     e
 mpint     n

Here the 'e' and 'n' parameters form the signature key blob.

The string is encoded as 32-bit big endian length followed by the literal string:


Encoding this sequence of bytes in Base64 gives:


The public exponent is also usually the same, so the common prefix is even longer. The bulk of the key is the public modulus, and that is completely different in different keys.


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.