sshd

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package sshd is the SSH server the agent runs itself.

`burrow ssh` does not forward to a system sshd: it starts this, which hands out a shell in the directory the command was run from, as the user who ran it. That means remote access to a machine with no sshd configured, no port opened and no root involved.

It only ever listens on loopback. Reaching it means coming through the tunnel, so the exposure is exactly the tunnel's lifetime and nothing is listening on the machine once the agent stops.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CurrentUser

func CurrentUser() string

CurrentUser is the account a session will run as, for the connect command.

func NewPassword

func NewPassword() string

NewPassword generates a session password.

Six words from a small alphabet rather than a long random string: it has to survive being read aloud and retyped, and 4 groups of 5 characters from this alphabet is still ~90 bits.

Types

type Server

type Server struct {
	// Dir is what a session starts in.
	Dir string
	// Password authenticates a session. Empty disables password auth.
	Password string
	// AuthorizedKeys may connect without a password.
	AuthorizedKeys []string
	// Log receives diagnostics.
	Log *slog.Logger
	// contains filtered or unexported fields
}

Server serves shells over SSH.

func New

func New(hostKeyPath string, s *Server) (*Server, error)

New prepares a server, loading or creating the persistent host key.

func (*Server) AuthorizedKeyCount added in v0.2.2

func (s *Server) AuthorizedKeyCount() int

AuthorizedKeyCount reports how many keys are currently accepted.

func (*Server) Close

func (s *Server) Close() error

Close stops the server and every live session.

func (*Server) Fingerprint

func (s *Server) Fingerprint() string

Fingerprint is the SHA256 fingerprint ssh prints on first connection.

func (*Server) HostKeyLine

func (s *Server) HostKeyLine(host string, port int) string

HostKeyLine returns the known_hosts entry for this server at addr, which is what lets someone connect without being asked to confirm a fingerprint.

func (*Server) Listen

func (s *Server) Listen() (net.Listener, error)

Listen opens the loopback listener the tunnel will point at.

func (*Server) Serve

func (s *Server) Serve(ln net.Listener) error

Serve handles connections until ln closes.

func (*Server) Sessions

func (s *Server) Sessions() int

Sessions reports how many shells are currently open.

func (*Server) SetAuthorizedKeys added in v0.2.2

func (s *Server) SetAuthorizedKeys(lines []string)

SetAuthorizedKeys replaces the accepted keys.

Callable while running, because the agent only learns them once the server answers its handshake — and again on every reconnect, so revoking a key in the panel takes effect without restarting anything.

Jump to

Keyboard shortcuts

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