testssh

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package testssh runs an in-process SSH server for tests.

It honours direct-tcpip channels, which is the mechanism an SSH port forward actually uses, so tests can prove a tunnel moves bytes rather than merely that it dials.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Echo

func Echo(t *testing.T) string

Echo starts a TCP echo server standing in for a remote service.

func Signer

func Signer(t *testing.T) ssh.Signer

Signer returns a fresh SSH key for tests.

Types

type Server

type Server struct {
	Addr    string
	HostKey ssh.PublicKey
	// contains filtered or unexported fields
}

Server is a running test SSH server.

func Start

func Start(t *testing.T) *Server

Start launches a server that forwards direct-tcpip channels.

func StartRejecting

func StartRejecting(t *testing.T) *Server

StartRejecting launches a server that refuses every forwarding attempt, for exercising the failure path.

func (*Server) Bastion

func (s *Server) Bastion(t *testing.T) *config.Tunnel

Bastion describes this server as a datasource tunnel configuration.

func (*Server) Stop added in v0.5.0

func (s *Server) Stop()

Stop takes the bastion away, closing the connections it has accepted along with the listener.

This is the event a session cannot see coming: a bastion restarted, a laptop suspended, a network moved. Rejecting new forwards would not do — the forwards already carrying a session would keep working, which is not what happens when a bastion goes.

Jump to

Keyboard shortcuts

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