Documentation
¶
Overview ¶
Package keys reads the private keys a credential can hold: OpenSSH and PEM keys, and PuTTY's .ppk (versions 2 and 3, encrypted or not), which it converts to OpenSSH. It also makes new ed25519 keys. What it returns is the OpenSSH key to keep in the keychain, with its public half.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrPassphraseNeeded is an encrypted key read without a passphrase. ErrPassphraseNeeded = errors.New("keys: the key is encrypted; a passphrase is needed") // ErrPassphraseWrong is a passphrase that does not open the key. ErrPassphraseWrong = errors.New("keys: wrong passphrase") // ErrNotAKey is data that is no private key this package reads. ErrNotAKey = errors.New("keys: not a private key") // ErrPublicKey is a public key given where a private one is wanted. ErrPublicKey = errors.New("keys: this is a public key; a private key is needed") // ErrCorrupt is a PuTTY key whose checksum does not match. ErrCorrupt = errors.New("keys: the key file is damaged") )
Functions ¶
Types ¶
type Key ¶
type Key struct {
// PEM is the OpenSSH (or PEM) private key, encrypted with its
// passphrase when it has one.
PEM []byte
// Public is the key's public half; for an encrypted legacy PEM key
// read without its passphrase it is nil.
Public ssh.PublicKey
// Encrypted reports that PEM needs a passphrase.
Encrypted bool
Comment string
}
Key is a private key ready to keep.
func Import ¶
Import reads a private key, OpenSSH, PEM or PuTTY .ppk. passphrase opens an encrypted one. An encrypted key read without it is ErrPassphraseNeeded; for an OpenSSH key the Key returned with it still has its public half, so it can be kept and opened later. A PuTTY key is converted to OpenSSH, encrypted with the same passphrase.
func (Key) AuthorizedLine ¶
AuthorizedLine is the key as a line of authorized_keys, without the newline: "type base64 comment".
func (Key) Fingerprint ¶
Fingerprint is the public key's SHA256 fingerprint, "" when unknown.
type UnsupportedError ¶
type UnsupportedError struct{ What string }
UnsupportedError is a key of a kind this package does not read, such as a DSA key or a PuTTY key derived with Argon2d.
func (*UnsupportedError) Error ¶
func (e *UnsupportedError) Error() string