keygen

package
v0.8.7 Latest Latest
Warning

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

Go to latest
Published: May 6, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

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

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 erorr. It implements the error interface.

func (FilesystemErr) Unwrap

func (e FilesystemErr) Unwrap() error

Unwrap returne the underlying error.

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 NewSSHKeyPair

func NewSSHKeyPair(passphrase []byte) (*SSHKeyPair, error)

NewSSHKeyPair generates an SSHKeyPair, which contains a pair of SSH keys. The keys are written to disk.

func (*SSHKeyPair) GenerateEd25519Keys

func (s *SSHKeyPair) GenerateEd25519Keys() error

GenerateEd25519Keys creates a pair of EdD25519 keys for SSH auth.

func (*SSHKeyPair) GenerateRSAKeys

func (s *SSHKeyPair) GenerateRSAKeys(bitSize int, passphrase []byte) error

GenerateRSAKeys creates a pair for RSA keys for SSH auth.

func (*SSHKeyPair) PrepFilesystem

func (s *SSHKeyPair) PrepFilesystem() error

PrepFilesystem makes sure the state of the filesystem is as it needs to be in order to write our keys to disk. It will create and/or set permissions on the SSH directory we're going to write our keys to (for example, ~/.ssh) as well as make sure that no files exist at the location in which we're going to write out keys.

func (*SSHKeyPair) WriteKeys

func (s *SSHKeyPair) WriteKeys() error

WriteKeys writes the SSH key pair to disk.

type SSHKeysAlreadyExistErr

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

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