gosshd

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package gosshd is an SSH server for WinPE guests.

Win32-OpenSSH cannot serve a session there. Per connection it spawns a pre-auth child as a virtual account — LsaManageSidNameMapping, then LogonUserExExW with LOGON32_PROVIDER_VIRTUAL — and authenticates the user with an S4U logon. WinPE supports no user logons at all, so both stages fail and the connection closes before authentication. Privilege separation has been mandatory upstream since 7.5, so there is no configuration that avoids it.

This server answers with a password callback in its own process and starts children with a plain CreateProcess, so no part of a session touches the Windows logon subsystem. The guest is a throwaway PE behind a host-only NAT reached over a per-run forwarded port, which is what makes a fixed password acceptable here.

Index

Constants

View Source
const (
	// DefaultAddr is the guest-side listen address. The host reaches it
	// through a per-run forwarded port, never directly.
	DefaultAddr = ":22"

	// DefaultUser and DefaultPassword are the credentials the guest is
	// built with. WinPE's Administrator has no password and no usable
	// account database, so these name nothing in Windows — they are only
	// this server's own shared secret with the harness.
	DefaultUser     = "admin"
	DefaultPassword = "admin"
)

Variables

This section is empty.

Functions

func SessionCommand

func SessionCommand(request string) []string

SessionCommand is the argv for a session. An empty request means the client asked for a shell rather than a single command.

cmd.exe rather than pwsh: WinPE always has it, and the harness stages pwsh at a path that is not on PATH.

Types

type Server

type Server struct {
	// Addr is the listen address, ":22" when empty.
	Addr string
	// User and Password are the only accepted credentials. Both empty
	// means no credentials are accepted at all.
	User, Password string
	// Log receives connection events. Discarded when nil.
	Log *log.Logger
	// contains filtered or unexported fields
}

Server serves one WinPE guest.

func (Server) Authenticate

func (s Server) Authenticate(user, password string) bool

Authenticate reports whether the offered credentials are the configured ones. A Server with no credentials configured accepts nothing, so a zero-value Server cannot be reached with an empty password.

func (Server) ListenAndServe

func (s Server) ListenAndServe() error

ListenAndServe serves until the listener fails.

func (Server) Serve

func (s Server) Serve(l net.Listener) error

Serve serves connections from l until it fails.

Directories

Path Synopsis
cmd
gosshd command
Command gosshd is the SSH server staged into a WinPE guest.
Command gosshd is the SSH server staged into a WinPE guest.

Jump to

Keyboard shortcuts

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