keys

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package keys scans the filesystem for SSH key pairs and reports them as config.Identity values. It performs no mutation; key generation/deletion lives elsewhere.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotImplemented = errors.New("not implemented")

ErrNotImplemented is returned by stubbed methods during scaffolding.

Functions

func GenerateCommand

func GenerateCommand(opts GenerateOpts) (*exec.Cmd, string, error)

GenerateCommand builds an interactive ssh-keygen command (no -N), so tea.ExecProcess can yield the terminal for a passphrase prompt. privPath is resolved against dir (or ~/.ssh when empty).

Types

type DiskScanner

type DiskScanner struct {
	Dir string // directory to scan; empty means ~/.ssh
}

DiskScanner scans a directory on disk (default ~/.ssh).

func New

func New(dir string) *DiskScanner

New returns a DiskScanner for dir. Empty dir defaults to ~/.ssh at Scan time.

func (*DiskScanner) Delete

func (s *DiskScanner) Delete(privPath string) error

Delete removes a key pair: the private key at privPath and its .pub sibling. A missing file is not an error; an empty path is refused as a safety guard.

func (*DiskScanner) Generate

func (s *DiskScanner) Generate(opts GenerateOpts) (config.Identity, error)

Generate creates a key pair with ssh-keygen and no passphrase, returning the new identity. For interactive use (passphrase prompt) prefer GenerateCommand with tea.ExecProcess. Refuses to overwrite an existing key.

func (*DiskScanner) Scan

func (s *DiskScanner) Scan() ([]config.Identity, error)

Scan discovers key pairs by locating *.pub files, parsing each public key, and pairing it with a private key of the same base name. A missing private key is reported via ExistsOnDisk=false rather than skipped. Unparseable or non-key files are ignored. The directory not existing yields an empty slice, not an error.

type GenerateOpts

type GenerateOpts struct {
	Dir       string // target directory; empty means the scanner's dir (~/.ssh)
	Name      string // private key file name, e.g. "id_ed25519"
	Comment   string // -C comment
	Algorithm config.KeyAlgorithm
	Bits      int // -b; ignored for ed25519
}

GenerateOpts describes a key to create with ssh-keygen.

type KeyScanner

type KeyScanner interface {
	Scan() ([]config.Identity, error)
	Generate(GenerateOpts) (config.Identity, error)
	Delete(privPath string) error
}

KeyScanner walks an SSH directory and pairs public/private keys into identities, and manages key files on disk (generation and deletion).

Jump to

Keyboard shortcuts

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