testserver

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: Apache-2.0 Imports: 21 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package testserver runs SSH servers on loopback for testing the SSH prober and for the demo targets: real servers from golang.org/x/crypto/ssh (an implementation independent of the prober's, so a misreading of the RFC cannot pass because both ends share it), and a scripted server for what no library will do (SSH-1 banners, preambles, hostile names, lists without strict key exchange, key exchanges no library implements).

Test and demo support only: the release binary must not import it (internal/archtest).

Index

Constants

View Source
const (
	KeyEd25519 = "ed25519"
	KeyECDSA   = "ecdsa-p256"
	KeyRSA     = "rsa-3072"
	KeyRSA1024 = "rsa-1024"
	KeyMLDSA65 = "mldsa65"
)

Key kinds a server may hold.

Variables

This section is empty.

Functions

func NewCompositeKey

func NewCompositeKey() (*compositeKey, error)

NewCompositeKey makes an ssh-mldsa44-ed25519 key.

Types

type Config

type Config struct {
	KeyExchanges []string
	Ciphers      []string
	MACs         []string
	// Keys are the host keys, by kind; default Ed25519.
	Keys []string
	// HostKeyAlgorithms restricts the RSA key's signature algorithms (for example to ssh-rsa only).
	RSAAlgorithms []string
	// Certificate signs the first host key with a CA and serves the certificate instead.
	Certificate bool
	Addr        string
}

Config configures an x/crypto server. Empty lists mean x/crypto's defaults.

type Script

type Script struct {
	Preamble   []string
	Ident      string // default "SSH-2.0-OpenSSH_9.6"
	Kex        []string
	HostKey    []string
	Ciphers    []string
	MACs       []string
	Comp       []string
	NoKexInit  bool // an SSH-1 server, or one that stops after the banner
	RawReplace []byte
}

Script is a server that sends a banner (and optional preamble lines) and, for SSH-2, a KEXINIT built from the given lists, then reads until the client goes away. It never runs a key exchange.

type Server

type Server struct {
	Host string
	Port int
	Addr string

	// Fingerprints are the SHA-256 fingerprints of the served host keys, in the order given.
	Fingerprints []string
	// contains filtered or unexported fields
}

Server is a running server.

func Listen

func Listen(cfg Config) (*Server, error)

Listen runs an x/crypto server; the caller closes it.

func ListenComposite

func ListenComposite(addr string, k *compositeKey) (*Server, error)

ListenComposite runs a server whose only host key is an ssh-mldsa44-ed25519 composite and whose only key exchange is curve25519-sha256.

func ListenScript

func ListenScript(addr string, sc Script) (*Server, error)

ListenScript runs a Script server; the caller closes it.

func Start

func Start(t testing.TB, cfg Config) *Server

Start runs an x/crypto server until the test ends.

func StartScript

func StartScript(t testing.TB, sc Script) *Server

StartScript runs a Script server until the test ends.

func (*Server) Close

func (s *Server) Close()

Close stops the server.

Jump to

Keyboard shortcuts

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