Documentation ¶
Overview ¶
Package sshkey implements parsing of SSH keys (authorized-keys format) and filtering of options.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNoKey is returned if parsing did not find a key. ErrNoKey = errors.New("no key found") // ErrMissingQuote is returned if a quoted option is lacking a closing quote. ErrMissingQuote = errors.New("missing quote") // ErrGarbage is returned if the key contains trailing garbage. ErrGarbage = errors.New("trailing garbage") // ErrInconsistentType is returned if the human-readable and the machine-readable key types do not match. ErrInconsistentType = errors.New("inconsistent key type") // ErrOption is returned if an option has a wrong format/value. ErrOption = errors.New("option wrong format") // ErrUnknownOption is returned when an unknown option is encountered. ErrUnknownOption = errors.New("unknown option") // ErrFormat is returned if formatting of values, especially expiry-time, is wrong. ErrFormat = errors.New("invalid format") )
Functions ¶
func ExpireTimeToString ¶
ExpireTimeToString returns the formatted expiry-time or an empty string if expiry is zero.
Types ¶
type BoolOption ¶
type BoolOption bool
BoolOption is a bool.
func (BoolOption) String ¶
func (boolOpt BoolOption) String() string
String returns a string representation of BoolOption.
type Key ¶
type Key struct { Options Options Key ssh.PublicKey Comment string NotAfter time.Time Fingerprint string }
Key is an annotaed SSH key.
func (Key) ApplyToString ¶
ApplyToString applies opts to a key and returns the authorized-key formatted result.
type Option ¶
type Option struct { Key string Value OptionValue }
Option is a single ssh-authorized-keys option.
type OptionValue ¶
type OptionValue interface {
String() string
}
OptionValue is the value an Option can take.
type Options ¶
type Options []Option
Options is a list of Option.
func ParseOptions ¶
ParseOptions parses options as if they are from an authorized-keys file, it does not fail on missing keys.
type StringOption ¶
type StringOption string
StringOption is a string.
func (StringOption) String ¶
func (StringOpt StringOption) String() string
String returns a string representation of StringOption.