Documentation
¶
Overview ¶
Package keystore generates and fingerprints SSH keys by shelling out to ssh-keygen. Generation is non-destructive by default (an existing private key is never clobbered) and perms are set on create.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GenResult ¶
type GenResult struct {
Path string
Fingerprint string
Created bool
// Type and Comment are what ssh-keygen was actually run with, set when
// Created. They differ from the request only for a hardware *-sk type that
// fell back to software (Fallback), so callers record the key that exists
// rather than the one asked for.
Type string
Comment string
Fallback bool
}
GenResult is the outcome of Generate. Created is false when the key already existed (an idempotent re-run).
type KeyStore ¶
type KeyStore struct{}
KeyStore mints and inspects keys.
func (*KeyStore) Fingerprint ¶
Fingerprint returns the SHA256:... fingerprint of a public or private key.
func (*KeyStore) Generate ¶
func (k *KeyStore) Generate(privPath, keyType, comment, passphrase string, overwrite bool) (GenResult, error)
Generate mints a keypair at privPath. Idempotent and non-destructive by default (an existing key is kept and its fingerprint returned); with overwrite the old pair is replaced (callers MUST have snapshotted ~/.ssh). A hardware *-sk type falls back to its software equivalent when no FIDO2 device is present.
func (*KeyStore) PublicFromPrivate ¶
PublicFromPrivate derives the public key from the private key material (ssh-keygen -y) - the only way to prove a keypair matches. It returns the public line (empty if it could not be derived) and whether the key is encrypted: empty + encrypted=true means a valid passphrase-protected key, empty + encrypted=false means an invalid/unreadable private key. err is non-nil only if ssh-keygen is absent.