Documentation
¶
Overview ¶
Package keygen handles the creation of new SSH key pairs.
Index ¶
- Variables
- type ErrUnsupportedKeyType
- type FilesystemErr
- type KeyPair
- func (s *KeyPair) AuthorizedKey() string
- func (s *KeyPair) CryptoPublicKey() crypto.PublicKey
- func (s *KeyPair) KeyPairExists() bool
- func (s *KeyPair) PrivateKey() crypto.PrivateKey
- func (s *KeyPair) PublicKey() ssh.PublicKey
- func (s *KeyPair) RawAuthorizedKey() []byte
- func (s *KeyPair) RawPrivateKey() []byte
- func (s *KeyPair) RawProtectedPrivateKey() []byte
- func (s *KeyPair) Signer() ssh.Signer
- func (s *KeyPair) WriteKeys() error
- type KeyType
- type Option
- type SSHKeyPair
- type SSHKeysAlreadyExistErr
Constants ¶
This section is empty.
Variables ¶
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 ¶ added in v0.3.0
type ErrUnsupportedKeyType struct {
// contains filtered or unexported fields
}
ErrUnsupportedKeyType indicates an unsupported key type.
func (ErrUnsupportedKeyType) Error ¶ added in v0.3.0
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 KeyPair ¶ added in v0.5.0
type KeyPair struct {
// contains filtered or unexported fields
}
KeyPair holds a pair of SSH keys and associated methods.
func New ¶ added in v0.1.1
New generates a KeyPair, which contains a pair of SSH keys.
If the key pair already exists, it will be loaded from disk, otherwise, a new SSH key pair is generated. If no key type is specified, Ed25519 will be used.
func (*KeyPair) AuthorizedKey ¶ added in v0.5.0
AuthorizedKey returns the SSH public key (RFC 4253) in OpenSSH authorized_keys format. The returned string is trimmed of sshd options and comments.
func (*KeyPair) CryptoPublicKey ¶ added in v0.5.0
CryptoPublicKey returns the crypto.PublicKey of the SSH key pair.
func (*KeyPair) KeyPairExists ¶ added in v0.5.0
KeyPairExists checks if the SSH key pair exists on disk.
func (*KeyPair) PrivateKey ¶ added in v0.5.0
func (s *KeyPair) PrivateKey() crypto.PrivateKey
PrivateKey returns the unencrypted crypto.PrivateKey.
func (*KeyPair) RawAuthorizedKey ¶ added in v0.5.0
RawAuthorizedKey returns the underlying SSH public key (RFC 4253) in OpenSSH authorized_keys format.
func (*KeyPair) RawPrivateKey ¶ added in v0.5.0
RawPrivateKey returns the raw unencrypted private key bytes in PEM format.
func (*KeyPair) RawProtectedPrivateKey ¶ added in v0.5.0
RawProtectedPrivateKey returns the raw password protected private key bytes in PEM format.
type KeyType ¶ added in v0.1.2
type KeyType string
KeyType represents a type of SSH key.
Supported key types.
type Option ¶ added in v0.4.0
type Option func(*KeyPair)
Option is a functional option for KeyPair.
func WithBitSize ¶ added in v0.4.0
WithBitSize sets the key size for the RSA key pair. This option is ignored for other key types.
func WithEllipticCurve ¶ added in v0.4.0
WithEllipticCurve sets the elliptic curve for the ECDSA key pair. Supported curves are P-256, P-384, and P-521. The default curve is P-384. This option is ignored for other key types.
func WithKeyType ¶ added in v0.4.0
WithKeyType sets the key type for the key pair. Available key types are RSA, Ed25519, and ECDSA.
func WithPassphrase ¶ added in v0.4.0
WithPassphrase sets the passphrase for the private key.
type SSHKeyPair ¶
type SSHKeyPair = KeyPair
SSHKeyPair holds a pair of SSH keys and associated methods. Deprecated: Use KeyPair instead.
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.