sshtest

package
v0.1.4792 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: MIT Imports: 13 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 sshtest is an SSH server on loopback for tests of magpie's SSH proxy: it logs a user in by password or key and answers each direct-tcpip channel (ssh -D's CONNECT) with an http.Handler of its own, so nothing a test sends through it leaves the machine.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewKey

func NewKey(t testing.TB) (ssh.Signer, string)

NewKey is a new ed25519 private key: the signer, and the key as an OpenSSH PEM a user would paste.

Types

type Options

type Options struct {
	User, Pass string
	Key        ssh.PublicKey // a key the user may log in with
	Handler    http.Handler
	HostSigner ssh.Signer // the server's host key; a new one when nil
	// Version is the banner, "SSH-2.0-Go" when empty; a real OpenSSH's
	// has a space ("SSH-2.0-OpenSSH_9.6p1 Ubuntu-3ubuntu13.20")
	Version string
	// Interactive offers keyboard-interactive and refuses it at once, as
	// OpenSSH without PAM does
	Interactive bool
	// Forward is how a forward is answered: "" carries it, "prohibit"
	// refuses it as AllowTcpForwarding no does, "hangup" ends the whole
	// connection as macOS 27's sshd does
	Forward string
}

Options are who may log in and what a channel opened through the server answers. A nil Handler answers "carried <host><path>".

type Server

type Server struct {
	Addr    string // host:port
	URL     string // ssh://host:port
	HostKey string // its host key, authorized_keys form
	// contains filtered or unexported fields
}

Server is one SSH server a test stood up; it ends with the test.

func Start

func Start(t testing.TB, o Options) *Server

Start stands the server up on 127.0.0.1.

func (*Server) Close

func (s *Server) Close()

Close ends the server's listener and leaves its connections up: a test of what a tunnel does when the server goes away.

func (*Server) Logins

func (s *Server) Logins() int

Logins is how many logins the server let in.

func (*Server) Targets

func (s *Server) Targets() []string

Targets is the host:port of every channel opened through the server.

Jump to

Keyboard shortcuts

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