edkey

package module
v0.0.0-...-3356ea4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 22, 2017 License: MIT Imports: 3 Imported by: 1

README

edkey

edkey allows you to marshal/write ED25519 private keys in the OpenSSH private key format

Example

package main

import (
	"crypto/rand"
	"encoding/pem"
	"io/ioutil"
	"github.com/mikesmitty/edkey"
	"golang.org/x/crypto/ed25519"
	"golang.org/x/crypto/ssh"
)

func main() {
	// Generate a new private/public keypair for OpenSSH
	pubKey, privKey, _ := ed25519.GenerateKey(rand.Reader)
	publicKey, _ := ssh.NewPublicKey(pubKey)

	pemKey := &pem.Block{
		Type:  "OPENSSH PRIVATE KEY",
		Bytes: edkey.MarshalED25519PrivateKey(privKey),
	}
	privateKey := pem.EncodeToMemory(pemKey)
	authorizedKey := ssh.MarshalAuthorizedKey(publicKey)

	_ = ioutil.WriteFile("id_ed25519", privateKey, 0600)
	_ = ioutil.WriteFile("id_ed25519.pub", authorizedKey, 0644)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MarshalED25519PrivateKey

func MarshalED25519PrivateKey(key ed25519.PrivateKey) []byte
Writes ed25519 private keys into the new OpenSSH private key format.

I have no idea why this isn't implemented anywhere yet, you can do seemingly everything except write it to disk in the OpenSSH private key format.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL