sshcert

package
v0.6.335 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package sshcert manages short-lived, per-environment SSH certificates and their backing ephemeral keypairs on disk for use by the OpenSSH client.

Index

Constants

View Source
const (
	LabelKeySSHProvider = "sshprovider"
	SSHProviderCertAuth = "certauth"
)

Label constants mirroring dev-plane's internal/labels package

View Source
const DefaultRenewalMargin = 60 * time.Second

DefaultRenewalMargin is how long before expiry we renew, to avoid a race where the cert expires between mint and the subsequent ssh use.

Variables

This section is empty.

Functions

func CertAuthorityPrincipal

func CertAuthorityPrincipal(nodeID, linuxUser string) string

CertAuthorityPrincipal returns the SSH certificate principal for a node and Linux user

func CertPath

func CertPath(brevDir, envID string) string

CertPath follows OpenSSH's <IdentityFile>-cert.pub convention, so a single IdentityFile directive loads both the key and the cert.

func CertValidAt

func CertValidAt(cert *ssh.Certificate, now time.Time, margin time.Duration) bool

func Dir

func Dir(brevDir string) string

func EnvironmentCertEligible

func EnvironmentCertEligible(labels map[string]string) bool

func GenerateKeyPair

func GenerateKeyPair() (privKeyPEM []byte, pubKeyOpenSSH string, err error)

func HasCertAuthorityLine

func HasCertAuthorityLine(homeDir, nodeID string) bool

HasCertAuthorityLine reports whether authorized_keys contains a Brev cert-authority line for the given node (any Linux user).

func HasValidCertAuth

func HasValidCertAuth(fs afero.Fs, keyPath, certPath string, now time.Time, margin time.Duration) (bool, error)

func KeyPath

func KeyPath(brevDir, envID string) string

func ParseCertificate

func ParseCertificate(certOpenSSH string) (*ssh.Certificate, error)

func PublicKeyMatches

func PublicKeyMatches(a, b ssh.PublicKey) bool

func RemoveCertAuthorityLine

func RemoveCertAuthorityLine(homeDir, nodeID, linuxUser string) (bool, error)

RemoveCertAuthorityLine removes the cert-authority line for the given node and Linux user from ~/.ssh/authorized_keys. Returns true if a line was removed. Missing file is treated as nothing-to-remove.

func WriteFiles

func WriteFiles(fs afero.Fs, keyPath, certPath string, privKeyPEM []byte, certOpenSSH string) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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