testsshd

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package testsshd is an in-process sshd so worker venues are testable without a network, a credential or a second machine; only OpenSSH's own config surface is missing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateKey

func GenerateKey(t testing.TB) (ssh.Signer, ssh.PublicKey, ed25519.PrivateKey)

GenerateKey returns one fresh ed25519 key in each form a test needs.

Types

type Server

type Server struct {
	URL        string
	Root       string
	HostKey    ssh.PublicKey
	Identity   string
	KnownHosts string

	Execs atomic.Int64
	// Must stay zero: OpenSSH ignores env requests without AcceptEnv, so a venue relying on them would pass here and fail in production.
	EnvRequests  atomic.Int64
	StreamLocals atomic.Int64
	// contains filtered or unexported fields
}

Server is a real sshd in every way a venue can observe: key auth, exec through a shell, exit-status, streamlocal.

func New

func New(t testing.TB) *Server

New accepts only the generated client key, and its URL names that key and the known_hosts holding this server's.

func NewWithConfig

func NewWithConfig(t testing.TB, config *ssh.ServerConfig, hostKey ssh.PublicKey) *Server

NewWithConfig serves config, whose auth and host key the caller chose; hostKey is the public half it added.

func (*Server) Addr

func (s *Server) Addr() string

Addr is host:port, for a test that builds its own mapping.

func (*Server) Dial

func (s *Server) Dial(t testing.TB) *ssh.Client

Dial is an ssh client authenticated as New's generated key, closed with the test.

func (*Server) URLWithHostKeyPin

func (s *Server) URLWithHostKeyPin(t testing.TB) string

URLWithHostKeyPin pins this server's actual key, which must be accepted.

func (*Server) URLWithPin

func (s *Server) URLWithPin(t testing.TB, fingerprint string) string

URLWithPin verifies the server by fingerprint instead of known_hosts, as a venue with no history does.

Jump to

Keyboard shortcuts

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