sshkey

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2026 License: MPL-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package sshkey implements a Packer data source that generates and caches SSH keys.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Name string `mapstructure:"name"`
	Type string `mapstructure:"type"`
}

Config holds the user-supplied HCL configuration for the sshkey data source.

func (*Config) FlatMapstructure

func (*Config) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec }

FlatMapstructure returns a new FlatConfig. FlatConfig is an auto-generated flat version of Config. Where the contents a fields with a `mapstructure:,squash` tag are bubbled up.

type Datasource

type Datasource struct {
	// contains filtered or unexported fields
}

Datasource is the Packer data source that generates or loads an SSH key pair.

func (*Datasource) ConfigSpec

func (d *Datasource) ConfigSpec() hcldec.ObjectSpec

ConfigSpec returns the HCL object spec for the data source inputs.

func (*Datasource) Configure

func (d *Datasource) Configure(raws ...any) error

Configure decodes HCL config into the datasource and applies defaults.

func (*Datasource) Execute

func (d *Datasource) Execute() (cty.Value, error)

Execute generates a new key or loads an existing one from the Packer cache.

func (*Datasource) OutputSpec

func (d *Datasource) OutputSpec() hcldec.ObjectSpec

OutputSpec returns the HCL object spec for the data source outputs.

type DatasourceOutput

type DatasourceOutput struct {
	PrivateKeyPath string `mapstructure:"private_key_path"`
	PublicKey      string `mapstructure:"public_key"`
}

DatasourceOutput is the value the data source exposes to downstream Packer config.

func (*DatasourceOutput) FlatMapstructure

func (*DatasourceOutput) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec }

FlatMapstructure returns a new FlatDatasourceOutput. FlatDatasourceOutput is an auto-generated flat version of DatasourceOutput. Where the contents a fields with a `mapstructure:,squash` tag are bubbled up.

type ED25519Key

type ED25519Key struct {
	// contains filtered or unexported fields
}

ED25519Key wraps an Ed25519 private key and implements the SSHKey interface.

func (*ED25519Key) FromPEM

func (k *ED25519Key) FromPEM(bytes []byte) error

FromPEM parses a PEM-encoded PKCS#8 private key and asserts it is Ed25519.

func (*ED25519Key) Generate

func (k *ED25519Key) Generate() error

Generate creates a new Ed25519 key pair using the system CSPRNG.

func (*ED25519Key) Public

func (k *ED25519Key) Public() (string, error)

Public returns the OpenSSH-format authorised-keys string for the Ed25519 key.

func (*ED25519Key) ToPEM

func (k *ED25519Key) ToPEM() ([]byte, error)

ToPEM serialises the Ed25519 private key as a PEM-encoded PKCS#8 block.

type FlatConfig

type FlatConfig struct {
	Name *string `mapstructure:"name" cty:"name" hcl:"name"`
	Type *string `mapstructure:"type" cty:"type" hcl:"type"`
}

FlatConfig is an auto-generated flat version of Config. Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.

func (*FlatConfig) HCL2Spec

func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec

HCL2Spec returns the hcl spec of a Config. This spec is used by HCL to read the fields of Config. The decoded values from this spec will then be applied to a FlatConfig.

type FlatDatasourceOutput

type FlatDatasourceOutput struct {
	PrivateKeyPath *string `mapstructure:"private_key_path" cty:"private_key_path" hcl:"private_key_path"`
	PublicKey      *string `mapstructure:"public_key" cty:"public_key" hcl:"public_key"`
}

FlatDatasourceOutput is an auto-generated flat version of DatasourceOutput. Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.

func (*FlatDatasourceOutput) HCL2Spec

func (*FlatDatasourceOutput) HCL2Spec() map[string]hcldec.Spec

HCL2Spec returns the hcl spec of a DatasourceOutput. This spec is used by HCL to read the fields of DatasourceOutput. The decoded values from this spec will then be applied to a FlatDatasourceOutput.

type RSAKey

type RSAKey struct {
	// contains filtered or unexported fields
}

RSAKey wraps an RSA private key and implements the SSHKey interface.

func (*RSAKey) FromPEM

func (k *RSAKey) FromPEM(bytes []byte) error

FromPEM parses a PEM-encoded PKCS#1 RSA private key.

func (*RSAKey) Generate

func (k *RSAKey) Generate() error

Generate creates a new RSA key pair using the system CSPRNG.

func (*RSAKey) Public

func (k *RSAKey) Public() (string, error)

Public returns the OpenSSH-format authorised-keys string for the RSA key.

func (*RSAKey) ToPEM

func (k *RSAKey) ToPEM() ([]byte, error)

ToPEM serialises the RSA private key as a PEM-encoded PKCS#1 block.

type SSHKey

type SSHKey interface {
	Generate() error
	ToPEM() ([]byte, error)
	FromPEM(bytes []byte) error
	Public() (string, error)
}

SSHKey is the common interface implemented by RSAKey and ED25519Key.

Jump to

Keyboard shortcuts

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