Search code examples
gorsafile-format

Creating or using GPG or SSH keys directly in Go


Are there any handy examples, libraries, etc. that read/save the RSA PublicKey and/or PrivateKey types from Go's crypto/rsa from/to GnuPG or OpenSSH key formats?

It's obviously not hard to write this, but surely a well routine is out there, if not for GnuPG or SSH then for OpenSSL, which can be converted to those.


Solution

  • All ssh-related methods are in golang.org/x/crypto/ssh
    (or now Dec. 2014: github.com/golang/crypto/tree/master/ssh, since Go switches to GitHub!).
    Read/Save RSA keys is manage in crypto/x509, as noted by the OP Jeff Burdges.

    You can see a good example in this project Scalingo/go-ssh-examples, which implements an ssh server(!) and client.
    It is also described in the article "Writing a replacement to OpenSSH using Go".