agent

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2026 License: Apache-2.0, Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsAgentStopped

func IsAgentStopped(err error) bool

IsAgentStopped returns true if the error indicates that the agent has been stopped

Types

type Agent

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

Agent represents an SSH agent that manages certificates.

Concurrency: Agent is safe for concurrent use. The keyring (golang.org/x/crypto/ssh/agent) has internal synchronization and can be safely accessed from multiple goroutines. The done channel and closeOnce provide safe shutdown coordination.

Immutable after creation: agentSocketPath, publicKey, privateKey, caClient, log Protected by internal sync: keyring (uses its own locking) Protected by closeOnce: agentListener, done channel

func New added in v0.1.1

func New(logger *slog.Logger, caClient *caclient.Client, agentSocketPath string) (*Agent, error)

New creates a new SSH agent. This does not start listening - call Serve() to begin accepting connections. If agentSocketPath is empty, a temporary socket will be created when Serve() is called.

func (*Agent) AgentSocketPath

func (a *Agent) AgentSocketPath() string

AgentSocketPath returns the path to the agent's Unix socket

func (*Agent) Close

func (a *Agent) Close()

Close stops the agent and cleans up resources. Safe to call multiple times.

func (*Agent) Done added in v0.1.1

func (a *Agent) Done() <-chan struct{}

Done returns a channel that is closed when the agent has been closed and cleanup is complete. This can be used with select statements or waitgroups to know when the agent is fully stopped.

func (*Agent) Running

func (a *Agent) Running() bool

Running returns true if the agent is currently running and accepting connections

func (*Agent) Serve added in v0.1.1

func (a *Agent) Serve(ctx context.Context) error

Serve starts the agent listening on the configured socket and blocks until the context is cancelled. Returns an error if the listener cannot be started, otherwise returns ctx.Err() when shutdown completes.

func (*Agent) UseCredential

func (a *Agent) UseCredential(c Credential) error

UseCredential replaces the current credentials in the agent with the provided credential

type Credential

type Credential struct {
	PrivateKey  sshcert.RawPrivateKey
	Certificate sshcert.RawCertificate
}

Credential contains the private key and certificate in PEM format

Jump to

Keyboard shortcuts

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