Encoding SSH RSA public key

robert robert.sicoie at gmail.com
Thu Aug 14 00:54:02 EST 2008


I'm trying to build a valid public ssh v2 RSA key from a java
application but I have some problems understanding how the two numbers
(e and n) are base64 encoded into ~/.ssh/id_rsa.pub or
~/.ssh/authorized_keys2 file.

My question is what exactly is encoded into the base64 string? For
example for this public key:

ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6p76zG+8aOkFZT1y4O+Y7n
+n0jWo6eW3DDPWVMddrR6z37uUsCZXPm1a6Inogp4NOt6UNaa1IrEtRkCWKF/kWoAzpVeJsJCXNc7EGzSBG9Q0JZ43F07X9mQHneUi+SKwDl/dp5O2Mnyi/az2OatyW1XNnpf94yJC1dhPnJSgXNAmp2R5Bq5qktzo0GMUfw11rdZzVNBMwgxZVp6mvuvgQFQ3xJVRIGE54IpW6iTXLOgxCSwL8Xj37fI22wOg7mYlNMIzyy3vUqyx73e00VnxxVp0DcaM347bFvyrRSm3hnBVDmdbTjP/ryHobNpSbPrP6vzNVww5Y61OFyTa60OPjQ== robert at robert

There must be options (optional), bits, e, n and comments (optional),
but how are these represented before encoding? Are each of these data
encoded to base64 separately and then concatenated? What exactly is

Could anyone describe me the algorithm for obtaining the base64 string?
I couldn't find it anywhere.


More information about the openssh-unix-dev mailing list