Is there a documentation of the key file formats?

Paul Ebermann Paul-Ebermann at gmx.de
Tue Nov 15 04:40:43 EST 2011


Hello,

part of a usual OpenSSH installation are quite some files containing key material,
like private keys (id_rsa, id_dsa, id_ecdsa) and the corresponding public keys
(id_rsa.pub, id_dsa.pub, id_ecdsa.pub).

Inspired by a recent question on Stack Overflow [1], I had a look at the
OpenSSH documentation to see what format these key files have.

The sshd man page [2] contains some paragraphs about the authorized_keys file,
but it says (for the case interesting me) only:

     Protocol 2 public key consist of: options, keytype, base64-encoded key,
     comment. 

Without any details on how the keys (for the different available types) are
actually encoded.

The known_hosts file format description (which should actually be in the
documentation for the client, not the daemon, I think) actually doesn't say
anything about protocol 2 keys:

     Each line in these files contains the following fields: markers
     (optional), hostnames, bits, exponent, modulus, comment.  The fields are
     separated by spaces.

This doesn't match the format in my ~/.ssh/known_hosts file at all (other
than the hostnames). There is also no explanation on how the hashed format
works.

I didn't find anything about the format of the private key files, yet there
are other tools which manage to use them (PuTTY has a converter, JSch can
use them for authentication).

So, my question: Is there any specification of the format of these files,
other than reading the OpenSSH source code which reads and writes these
files?


Thanks
Paŭlo


[1] "What are the key file formats of JSch and sharpSSH?"
    http://stackoverflow.com/q/8114903/600500
[2] http://www.openbsd.org/cgi-bin/man.cgi?query=sshd&sektion=8


More information about the openssh-unix-dev mailing list