server

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2026 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentAuth

type AgentAuth struct {
	Agent sshagent.Agent
}

AgentAuth implements AuthKeySource using keys listed by an SSH agent.

func (*AgentAuth) Authorized

func (a *AgentAuth) Authorized(key ssh.PublicKey) bool

Authorized returns true if the given public key is one of the keys in the agent.

type AuthKeySource

type AuthKeySource interface {
	Authorized(key ssh.PublicKey) bool
}

AuthKeySource provides authorized-key checks for the SSH server. Implementations must use constant-time comparison when comparing keys.

type FileAuth

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

FileAuth implements AuthKeySource by reading authorized keys from a file (e.g. OpenSSH authorized_keys format). The file is read at construction. Changes to the file require a new FileAuth.

func NewFileAuth

func NewFileAuth(path string) (*FileAuth, error)

NewFileAuth reads the file at path and parses it as authorized_keys (one key per line, ssh.ParseAuthorizedKey). Returns an error if the file cannot be read; invalid lines are skipped.

func (*FileAuth) Authorized

func (f *FileAuth) Authorized(key ssh.PublicKey) bool

Authorized returns true if the given public key matches one of the keys in the file.

type Server

type Server struct {
	ListenAddr  string
	AuthKeys    AuthKeySource
	HostKeyPath string
}

Server is a TCP SSH server that authenticates by public key and serves a simple session message. It does not depend on config or CLI; all data is passed via struct fields.

func (*Server) ListenAndServe

func (s *Server) ListenAndServe() error

ListenAndServe starts the SSH server on s.ListenAddr. It does not return until the server exits. If HostKeyPath is set, that file is used; otherwise an ephemeral in-memory key is used for this process.

Jump to

Keyboard shortcuts

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