sshkeys

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: BSD-3-Clause Imports: 6 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 sshkeys parses and classifies the SSH public keys users register. The accepted set is deliberately small: no DSA, no certificates, no authorized_keys options (a registered key grants exactly "authenticate as the account", nothing a line could widen), no short RSA keys.

Index

Constants

View Source
const (
	// MaxLineLen bounds a registered authorized_keys line.
	MaxLineLen = 8 << 10
	// MaxCommentLen bounds the comment kept with a key.
	MaxCommentLen = 128
	// MinRSABits is the smallest RSA modulus accepted.
	MinRSABits = 3072
)

Bounds.

Variables

View Source
var ErrInvalid = errors.New("invalid ssh public key")

ErrInvalid wraps every refusal of a key.

Functions

func Allowed

func Allowed(t string) bool

Allowed reports whether an SSH key algorithm name is one the forge accepts.

func IsSecurityKeyType

func IsSecurityKeyType(t string) bool

IsSecurityKeyType reports whether an SSH algorithm name is a FIDO-backed key.

Types

type Key

type Key struct {
	// Type is the SSH algorithm name.
	Type string
	// Blob is the key in SSH wire format.
	Blob []byte
	// Fingerprint is "SHA256:<unpadded base64>".
	Fingerprint string
	// Comment is the trailing comment of the line, possibly empty.
	Comment string
	// SecurityKey is true for the FIDO-backed "sk-" types.
	SecurityKey bool
	// Public is the key itself, for the SSH server's comparison.
	Public ssh.PublicKey
}

Key is a parsed, accepted public key.

func Parse

func Parse(line string) (Key, error)

Parse reads one authorized_keys line of the form "<type> <base64> [comment]". A line with options in front, a certificate, an algorithm outside the accepted set, a short RSA key, or a trailing blob is refused.

func ParseBlob

func ParseBlob(blob []byte, comment string) (Key, error)

ParseBlob rebuilds a Key from its wire encoding, as stored.

Jump to

Keyboard shortcuts

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