authkeys

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 2, 2026 License: MIT Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

Constants

This section is empty.

Variables

View Source
var ErrNotAPublicKey = errors.New("not a valid public key")

ErrNotAPublicKey is returned by AddKeyToText for a non-key line.

View Source
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

func AddKeyToText(text, newLine string) (out string, added bool, err error)

AddKeyToText appends newLine unless its body is already present.

func CountKeys

func CountKeys(text string) int

CountKeys returns how many real keys are in the text.

func IsValidPublicKey

func IsValidPublicKey(line string) bool

IsValidPublicKey reports whether the line parses as a real OpenSSH public key.

func KeyBody

func KeyBody(line string) string

KeyBody returns the base64 body of a key line (its stable identity), or "".

func KeyLines

func KeyLines(text string) []string

KeyLines returns the real key lines (blanks/comments/junk dropped).

func RemoveKeyFromText

func RemoveKeyFromText(text, targetLine string) (out string, removed int)

RemoveKeyFromText removes every line whose body matches targetLine.

func SameKey

func SameKey(a, b string) bool

SameKey reports whether two lines carry the same key body.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL