Documentation
¶
Overview ¶
Package keys handles SSH key operations: loading, saving, generating, formatting, and editing comments. Supports RSA, ECDSA, and Ed25519.
Index ¶
- func DefaultComment() string
- func FormatPublicKey(signer ssh.Signer, comment string) string
- func Generate(keyType string, bits int, comment string) (privPEM []byte, pubAuth []byte, err error)
- func LoadKeyMaterial(path string) (*openssh.ParsedKey, interface{}, ssh.Signer, error)
- func PublicKeyFromPEM(privPEM []byte) (ssh.PublicKey, interface{}, error)
- func SavePair(dir, filename string, privPEM, pubAuth []byte) error
- func SaveWithComment(rawKey interface{}, comment, privPath string) error
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 ¶
FormatPublicKey returns an authorized_keys-formatted line with comment.
func Generate ¶
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 ¶
LoadKeyMaterial reads a key file and returns parsed metadata, raw key, and signer.
func PublicKeyFromPEM ¶
PublicKeyFromPEM parses a private key PEM blob and returns its public key and raw key.
func SavePair ¶
SavePair writes the private key with 0600 permissions and the public key (.pub) with 0644 permissions to the specified directory.
func SaveWithComment ¶
SaveWithComment writes private key material with an updated comment and updates the .pub companion file when it exists.
Types ¶
This section is empty.