keys

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2026 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

Package keys handles SSH key operations: loading, saving, generating, formatting, and editing comments. Supports RSA, ECDSA, and Ed25519.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultComment

func DefaultComment() string

DefaultComment returns a best-effort "user@host" comment.

func FormatPublicKey

func FormatPublicKey(signer ssh.Signer, comment string) string

FormatPublicKey returns an authorized_keys-formatted line with comment.

func Generate

func Generate(keyType string, bits int, comment string) (privPEM []byte, pubAuth []byte, err error)

Generate creates an SSH key pair of the specified type and returns the PEM-encoded private key and authorized_keys-format public key.

func LoadKeyMaterial

func LoadKeyMaterial(path string) (*openssh.ParsedKey, interface{}, ssh.Signer, error)

LoadKeyMaterial reads a key file and returns parsed metadata, raw key, and signer.

func PublicKeyFromPEM

func PublicKeyFromPEM(privPEM []byte) (ssh.PublicKey, interface{}, error)

PublicKeyFromPEM parses a private key PEM blob and returns its public key and raw key.

func SavePair

func SavePair(dir, filename string, privPEM, pubAuth []byte) error

SavePair writes the private key with 0600 permissions and the public key (.pub) with 0644 permissions to the specified directory.

func SaveWithComment

func SaveWithComment(rawKey interface{}, comment, privPath string) error

SaveWithComment writes private key material with an updated comment and updates the .pub companion file when it exists.

Types

This section is empty.

Jump to

Keyboard shortcuts

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