Documentation
¶
Overview ¶
Package authkeys has pure helpers for editing an authorized_keys file. Keys are matched by their base64 wire-format body (validated as a real key blob), so a key is deduped/removed regardless of comments or options, and junk lines are ignored.
Index ¶
- Variables
- func AddKeyToText(text, newLine string) (out string, added bool, err error)
- func CountKeys(text string) int
- func IsValidPublicKey(line string) bool
- func KeyBody(line string) string
- func KeyLines(text string) []string
- func RemoveKeyFromText(text, targetLine string) (out string, removed int)
- func SameKey(a, b string) bool
Constants ¶
This section is empty.
Variables ¶
var ErrNotAPublicKey = errors.New("not a valid public key")
ErrNotAPublicKey is returned by AddKeyToText for a non-key line.
var KeyTypes = map[string]bool{ "ssh-rsa": true, "ssh-dss": true, "ssh-ed25519": true, "ecdsa-sha2-nistp256": true, "ecdsa-sha2-nistp384": true, "ecdsa-sha2-nistp521": true, "sk-ssh-ed25519@openssh.com": true, "sk-ecdsa-sha2-nistp256@openssh.com": true, }
KeyTypes are the OpenSSH public-key type tokens (the token before the body).
Functions ¶
func AddKeyToText ¶
AddKeyToText appends newLine unless its body is already present.
func IsValidPublicKey ¶
IsValidPublicKey reports whether the line parses as a real OpenSSH public key.
func RemoveKeyFromText ¶
RemoveKeyFromText removes every line whose body matches targetLine.
Types ¶
This section is empty.