keys

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package keys generates and encodes SSH key pairs (ed25519 or RSA) using only the standard library plus golang.org/x/crypto/ssh for SSH wire encoding.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadSigner

func LoadSigner(privPath string) (ssh.Signer, error)

LoadSigner reads a private key PEM file and returns an ssh.Signer for auth. If the key is passphrase-protected it prompts for the passphrase (no echo).

func ReadPublic

func ReadPublic(pubPath string) (string, error)

ReadPublic returns the stored authorized_keys line for display/installation.

Types

type Pair

type Pair struct {
	PrivatePEM  []byte
	PublicAuth  []byte // single authorized_keys line, newline-terminated
	Fingerprint string
}

Pair holds the encoded private (OpenSSH PEM) and public (authorized_keys line) representations of a freshly generated key, plus its fingerprint.

func Generate

func Generate(t config.KeyType, bits int, comment string) (*Pair, error)

Generate creates a new key pair. For RSA, bits defaults to 3072 when <=0.

func (*Pair) Write

func (p *Pair) Write(dir, name string) (privPath, pubPath string, err error)

Write stores the pair as <dir>/<name> (private, 0600) and <dir>/<name>.pub (public, 0644) and returns the two paths.

Jump to

Keyboard shortcuts

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