Skip to content

Instantly share code, notes, and snippets.

@axw
Created December 18, 2013 01:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save axw/8016123 to your computer and use it in GitHub Desktop.
Save axw/8016123 to your computer and use it in GitHub Desktop.
Translate PEM key to authorized_key
package main
import (
"fmt"
"io/ioutil"
"log"
"code.google.com/p/go.crypto/ssh"
)
func main() {
bytes, err := ioutil.ReadFile("/home/andrew/.juju/local-private-key.pem")
if err != nil {
log.Fatal(err)
}
signer, err := ssh.ParsePrivateKey(bytes)
if err != nil {
log.Fatalf("failed to load key: %v", err)
}
ak := ssh.MarshalAuthorizedKey(signer.PublicKey())
fmt.Println(string(ak))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment