Categorygithub.com/charmbracelet/keygen
modulepackage
0.5.0
Repository: https://github.com/charmbracelet/keygen.git
Documentation: pkg.go.dev

# README

Keygen

Latest Release GoDoc Build Status Go ReportCard

An SSH key pair generator with password protected keys support. Supports generating RSA, ECDSA, and Ed25519 keys.

Example

kp, err := keygen.New("awesome", keygen.WithPassphrase("awesome_secret"),
	keygen.WithKeyType(keygen.Ed25519))
if err != nil {
	log.Fatalf("error creating SSH key pair: %v", err)
}
fmt.Printf("Your authorized key: %s\n", kp.AuthorizedKey())

Feedback

We’d love to hear your thoughts on this project. Feel free to drop us a note!

License

MIT


Part of Charm.

The Charm logo

Charm热爱开源 • Charm loves open source

# Functions

New generates a KeyPair, which contains a pair of SSH keys.
WithBitSize sets the key size for the RSA key pair.
WithEllipticCurve sets the elliptic curve for the ECDSA key pair.
WithKeyType sets the key type for the key pair.
WithPassphrase sets the passphrase for the private key.
WithWrite writes the key pair to disk if it doesn't exist.

# Constants

Supported key types.
Supported key types.
Supported key types.

# Variables

ErrMissingSSHKeys indicates we're missing some keys that we expected to have after generating.

# Structs

ErrUnsupportedKeyType indicates an unsupported key type.
FilesystemErr is used to signal there was a problem creating keys at the filesystem-level.
KeyPair holds a pair of SSH keys and associated methods.
SSHKeysAlreadyExistErr indicates that files already exist at the location at which we're attempting to create SSH keys.

# Type aliases

KeyType represents a type of SSH key.
Option is a functional option for KeyPair.
SSHKeyPair holds a pair of SSH keys and associated methods.