ssh

package
v2.282.0 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package ssh provides SSH-style token generation and verification for go-service.

Tokens are generated as `<name>-<base64(signature)>`, where the signature is computed over the key name and verified using the configured public keys.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Key is the signing key configuration used to mint SSH tokens.
	Key *Key `yaml:"key,omitempty" json:"key,omitempty" toml:"key,omitempty"`

	// Keys is the set of verification keys that may be used to validate SSH tokens.
	Keys Keys `yaml:"keys,omitempty" json:"keys,omitempty" toml:"keys,omitempty"`
}

Config configures SSH token key material.

It supports a single signing key (Key) and a set of verification keys (Keys).

func (*Config) IsEnabled added in v2.115.0

func (c *Config) IsEnabled() bool

IsEnabled reports whether SSH token configuration is present and contains at least one key.

type Key

type Key struct {
	// Config contains the SSH key material configuration (public/private key sources).
	*ssh.Config `yaml:",inline" json:",inline" toml:",inline"`

	// Name is the logical key name used to select a key (for example via Keys.Get).
	Name string `yaml:"name,omitempty" json:"name,omitempty" toml:"name,omitempty"`
}

Key describes an SSH key configuration along with its logical name.

The embedded `ssh`.Config provides the key material source/loading configuration.

type Keys

type Keys []*Key

Keys is a list of named SSH keys.

func (Keys) Get

func (c Keys) Get(name string) *Key

Get returns the key with the given name, or nil if no matching key exists.

type Signer added in v2.9.0

type Signer = ssh.Signer

Signer aliases `crypto/ssh`.Signer.

type Token

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

Token generates and verifies SSH-style tokens.

func NewToken

func NewToken(cfg *Config, fs *os.FS) *Token

NewToken constructs a Token using cfg and fs.

If cfg is disabled, it returns nil.

func (*Token) Generate

func (t *Token) Generate() (string, error)

Generate creates an SSH-style token.

The token format is `<name>-<base64(signature)>`, where signature is computed over the key name using the configured signing key.

func (*Token) Verify

func (t *Token) Verify(token string) (string, error)

Verify validates token and returns the key name if it is valid.

It expects token in the format `<name>-<base64(signature)>` and verifies the signature over `<name>` using the configured verification keys.

type Verifier added in v2.9.0

type Verifier = ssh.Verifier

Verifier aliases `crypto/ssh`.Verifier.

Jump to

Keyboard shortcuts

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