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 ( // ErrNotACert is data that is no OpenSSH certificate. ErrNotACert = errors.New("keys: not an OpenSSH certificate") // ErrHostCert is a host certificate given where a user one is wanted. ErrHostCert = errors.New("keys: a host certificate, not a user certificate") // ErrCertMismatch is a certificate of another key than the private key. ErrCertMismatch = errors.New("keys: the certificate is not for this private key") )
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 Cert ¶ added in v0.0.9
type Cert struct {
*ssh.Certificate
// Line is the certificate as one authorized_keys line, as kept.
Line string
}
Cert is an OpenSSH user certificate (a key-cert.pub file): a public key signed by a certificate authority, offered with its private key.
func (Cert) CAFingerprint ¶ added in v0.0.9
CAFingerprint is the SHA256 fingerprint of the authority that signed it.
func (Cert) KeyFingerprint ¶ added in v0.0.9
KeyFingerprint is the SHA256 fingerprint of the certified key, the one its private key must have.
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