Documentation ¶
Overview ¶
Package edkey converts ed25519 private keys to OpenSSH PEM format.
Example ¶
/* Predictable random source. Please don't do this in real code. */ rs := rand.New(rand.NewSource(0)) /* Generate an ED25519 key and PEMify it. */ _, kr, err := ed25519.GenerateKey(rs) if nil != err { log.Fatalf("Error generating key: %s", err) } spem, err := ToPEM(kr, "A fancy example key") if nil != err { log.Fatalf("Error converting to OpenSSH PEM format: %s", err) } /* spem can now be written to disk and passed to ssh -i. */ /* We can also use it with x/crypto/ssh. */ s, err := ssh.ParsePrivateKey(spem) if nil != err { log.Fatalf("Parsing PEM: %s", err) } fmt.Printf( "Fingerprint: %s\n", ssh.FingerprintSHA256(s.PublicKey()), )
Output: Fingerprint: SHA256:Wa1InoB8MuILNZy9CjDRvHn9c6afuXSwS7Vm+/addOA
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ToPEM ¶
func ToPEM(key ed25519.PrivateKey, comment string) ([]byte, error)
ToPEM encodes a ed25519 private key into the OpenSSH PEM private key format, optionally setting a comment (ssh-keygen -C -style). The returned slice is suitable to be written to a file and passed to OpenSSH via -i/-oIdentityFile.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.