sshkeygen

package
v0.0.0-...-1aef7fd Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package sshkeygen provides the ssh-keygen utility — generate, manage, and convert SSH keys.

It exposes a Config struct with a Parse method for command-line argument parsing, individual action functions (Generate, Fingerprint, ChangePassphrase, ShowPublicKey, ChangeComment), and a Run dispatcher.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChangeComment

func ChangeComment(cfg *Config, streams stdio.TerminalStreams) int

ChangeComment changes the comment on a key file.

func ChangePassphrase

func ChangePassphrase(cfg *Config, streams stdio.TerminalStreams) int

ChangePassphrase changes the passphrase on an existing private key.

func Fingerprint

func Fingerprint(cfg *Config, streams stdio.TerminalStreams) int

Fingerprint prints the fingerprint of a key file and returns an exit code.

func FingerprintString

func FingerprintString(key ssh.PublicKey, algo string) string

FingerprintString returns the fingerprint string for a public key using the specified hash algorithm ("md5" or "sha256").

func Generate

func Generate(cfg *Config, streams stdio.TerminalStreams) int

Generate generates a new SSH key pair.

func KeySize

func KeySize(key ssh.PublicKey) int

KeySize returns the key size in bits for the given public key.

func KeyTypeName

func KeyTypeName(key ssh.PublicKey) string

KeyTypeName returns a human-readable name for the SSH key type.

func ParseKeyTypes

func ParseKeyTypes(spec string) []string

ParseKeyTypes translates user-friendly type names to SSH algorithm names.

func Run

func Run(cfg *Config, streams stdio.TerminalStreams) int

Run dispatches to the appropriate action based on cfg and returns a process exit code.

func ShowPublicKey

func ShowPublicKey(cfg *Config, streams stdio.TerminalStreams) int

ShowPublicKey extracts and prints the public key from a private key file.

Types

type Config

type Config struct {
	KeyType       string // -t
	Bits          int    // -b
	Comment       string // -C
	KeyFile       string // -f
	NewPass       string // -N
	OldPass       string // -P (old passphrase for -p)
	Fingerprint   bool   // -l
	ChangePass    bool   // -p
	ChangeComment bool   // -c
	ShowPub       bool   // -y
	HashAlgo      string // -E (md5 or sha256)
	Quiet         bool   // -q
	Version       bool   // -V
}

Config holds parsed ssh-keygen command-line arguments.

func (*Config) Parse

func (cfg *Config) Parse(args ...string) error

Parse populates cfg from command-line arguments. Fields set before calling Parse are preserved unless overridden. Default values: KeyType="ed25519", HashAlgo="sha256".

Jump to

Keyboard shortcuts

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