ssh

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package ssh implements dynamic OpenSSH user certificate credentials (signed-key mode).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CertOptions

type CertOptions struct {
	KeyID           string
	Principals      []string
	ValidAfter      time.Time
	ValidBefore     time.Time
	Extensions      map[string]string
	CriticalOptions map[string]string
}

CertOptions configures an OpenSSH user certificate.

type CredsRequest

type CredsRequest struct {
	Role      string
	Username  string
	TTLSecond int
	// TokenID is the hashed client token that issued the lease (cascade revoke).
	TokenID string
	// Tenant / TenantMode scope lease IDs (W64-01).
	Tenant     string
	TenantMode bool
}

CredsRequest configures credential generation.

type CredsResult

type CredsResult struct {
	LeaseID    string
	Username   string
	PrivateKey string
	SignedKey  string
	Role       string
	TTLSeconds int
	MaxTTL     int
	ExpiresAt  time.Time
	Warnings   []string
}

CredsResult contains generated SSH credentials and lease metadata.

type Engine

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

Engine generates short-lived OpenSSH user certificates bound to leases.

func NewEngine

func NewEngine(
	roles repository.SSHRoleRepository,
	leases repository.LeaseRepository,
	secrets repository.SecretRepository,
	cryptoSvc *crypto.Service,
) *Engine

NewEngine constructs an SSH credentials engine.

func (*Engine) CleanupExpired

func (e *Engine) CleanupExpired(ctx context.Context, limit int) (int, error)

CleanupExpired revokes expired ssh leases.

func (*Engine) GenerateCredentials

func (e *Engine) GenerateCredentials(ctx context.Context, req CredsRequest) (*CredsResult, error)

GenerateCredentials creates an ephemeral SSH key pair and signed user certificate.

func (*Engine) GetRole

func (e *Engine) GetRole(ctx context.Context, name string) (*domainsecrets.SSHRole, error)

GetRole returns role configuration.

func (*Engine) Name

func (e *Engine) Name() string

Name returns the engine identifier.

func (*Engine) Renew

func (e *Engine) Renew(ctx context.Context, leaseID string, ttlSeconds int) (*CredsResult, error)

Renew extends an active lease and re-signs the user certificate.

func (*Engine) RenewExpiring

func (e *Engine) RenewExpiring(ctx context.Context, grace time.Duration, limit int) (int, error)

RenewExpiring renews active leases expiring within grace (W42-06).

func (*Engine) RevokeLease

func (e *Engine) RevokeLease(ctx context.Context, leaseID string) error

RevokeLease revokes a lease and destroys stored credentials.

func (*Engine) SaveRole

func (e *Engine) SaveRole(ctx context.Context, cfg RoleConfig) error

SaveRole stores or updates role configuration.

type RegistryAdapter

type RegistryAdapter struct {
	*Engine
}

RegistryAdapter wraps the ssh engine for engine.Registry registration.

func NewRegistryAdapter

func NewRegistryAdapter(engine *Engine) RegistryAdapter

NewRegistryAdapter constructs a SecretEngine adapter for the ssh engine.

func (RegistryAdapter) Get

func (a RegistryAdapter) Get(_ context.Context, _ string) (map[string]any, error)

Get is not supported; ssh credentials are generated via roles.

func (RegistryAdapter) Put

func (a RegistryAdapter) Put(_ context.Context, _ string, _ map[string]any) error

Put is not supported; ssh credentials are generated via roles.

type RoleConfig

type RoleConfig struct {
	Name         string
	TTLSeconds   int
	DefaultTTL   int
	MaxTTL       int
	Period       int
	Renewable    *bool
	MaxLeases    int
	CAKeyPath    string
	AllowedUsers []string
	DefaultUser  string
	KeyType      string
	Extensions   map[string]string
}

RoleConfig configures an SSH credential role.

Jump to

Keyboard shortcuts

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