keygen

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2022 License: MIT Imports: 17 Imported by: 19

README

Keygen

Latest Release GoDoc Build Status Go ReportCard

An SSH key pair generator. Supports generating RSA and Ed25519 keys.

Example

k, err := NewWithWrite(".ssh", "my_awesome_key", []byte(""), key.Ed25519)
if err != nil {
	fmt.Printf("error creating SSH key pair: %v", err)
	os.Exit(1)
}

License

MIT


Part of Charm.

the Charm logo

Charm热爱开源 • Charm loves open source

Documentation

Overview

Package keygen handles the creation of new SSH key pairs.

Index

Constants

This section is empty.

Variables

View Source
var ErrMissingSSHKeys = errors.New("missing one or more keys; did something happen to them after they were generated?")

ErrMissingSSHKeys indicates we're missing some keys that we expected to have after generating. This should be an extreme edge case.

Functions

This section is empty.

Types

type FilesystemErr

type FilesystemErr struct {
	Err error
}

FilesystemErr is used to signal there was a problem creating keys at the filesystem-level. For example, when we're unable to create a directory to store new SSH keys in.

func (FilesystemErr) Error

func (e FilesystemErr) Error() string

Error returns a human-readable string for the error. It implements the error interface.

func (FilesystemErr) Unwrap

func (e FilesystemErr) Unwrap() error

Unwrap returne the underlying error.

type KeyType added in v0.1.2

type KeyType string

KeyType represents a type of SSH key.

const (
	RSA     KeyType = "rsa"
	Ed25519 KeyType = "ed25519"
	ECDSA   KeyType = "ecdsa"
)

Supported key types.

type SSHKeyPair

type SSHKeyPair struct {
	PrivateKeyPEM []byte
	PublicKey     []byte
	KeyDir        string
	Filename      string // private key filename; public key will have .pub appended
}

SSHKeyPair holds a pair of SSH keys and associated methods.

func New added in v0.1.1

func New(path, name string, passphrase []byte, keyType KeyType) (*SSHKeyPair, error)

New generates an SSHKeyPair, which contains a pair of SSH keys.

func NewWithWrite added in v0.1.1

func NewWithWrite(path, name string, passphrase []byte, keyType KeyType) (*SSHKeyPair, error)

NewWithWrite generates an SSHKeyPair and writes it to disk if not exist.

func (*SSHKeyPair) IsKeyPairExists added in v0.1.1

func (s *SSHKeyPair) IsKeyPairExists() bool

IsKeyPairExists checks if the SSH key pair exists on disk.

func (*SSHKeyPair) WriteKeys

func (s *SSHKeyPair) WriteKeys() error

WriteKeys writes the SSH key pair to disk.

type SSHKeysAlreadyExistErr

type SSHKeysAlreadyExistErr struct {
	Path string
}

SSHKeysAlreadyExistErr indicates that files already exist at the location at which we're attempting to create SSH keys.

func (SSHKeysAlreadyExistErr) Error

func (e SSHKeysAlreadyExistErr) Error() string

Error returns the a human-readable error message for SSHKeysAlreadyExistErr. It satisfies the error interface.

Jump to

Keyboard shortcuts

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