keygen

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2022 License: Apache-2.0 Imports: 17 Imported by: 0

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 ErrUnsupportedKeyType

type ErrUnsupportedKeyType struct {
	// contains filtered or unexported fields
}

ErrUnsupportedKeyType indicates an unsupported key type.

func (ErrUnsupportedKeyType) Error

func (e ErrUnsupportedKeyType) Error() string

Error implements the error interface for ErrUnsupportedKeyType

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 returns the underlying error.

type KeyType

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 {
	// contains filtered or unexported fields
}

SSHKeyPair holds a pair of SSH keys and associated methods.

func New

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

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

func NewWithWrite

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

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

func (*SSHKeyPair) KeyPairExists

func (s *SSHKeyPair) KeyPairExists() bool

KeyPairExists checks if the SSH key pair exists on disk.

func (*SSHKeyPair) PrivateKey

func (s *SSHKeyPair) PrivateKey() crypto.PrivateKey

PrivateKey returns the unencrypted private key.

func (*SSHKeyPair) PrivateKeyPEM

func (s *SSHKeyPair) PrivateKeyPEM() []byte

PrivateKeyPEM returns the unencrypted private key in OPENSSH PEM format.

func (*SSHKeyPair) PublicKey

func (s *SSHKeyPair) PublicKey() []byte

PublicKey returns the SSH public key (RFC 4253). Ready to be used in an OpenSSH authorized_keys file.

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