Skip to content
Snippets Groups Projects
Select Git revision
  • 321e26fae746e661d713cedfb6642609e680cafe
  • ballinvoher default protected
  • client-http-server-for-token
  • master
  • gitlab-auth-issue
  • windows
  • microsoft
  • message
  • azure_auth
  • prometheus
  • permission-templates
  • no-datastore
  • save-public-keys
  • gitlab-group-level-start
  • v1.1.0
  • v1.0.0
  • v0.1
17 results

edkey

  • Clone with SSH
  • Clone with HTTPS
  • user avatar
    fuero authored and Niall Sheridan committed
    * enables saving private keys
    
    * renames public_file_prefix to key_file_prefix and updates its docs to better reflect the changes
    321e26fa
    History
    Name Last commit Last update
    ..
    LICENSE
    README.md
    edkey.go

    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)
    }