sshx

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: MIT Imports: 19 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 sshx dials hosts from the inventory (with jump-host chains, keychain/agent/password auth and TOFU host-key checking) and runs commands.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildCommand

func BuildCommand(c *Client, r RunRequest) (cmd string, stdinPrefix []byte, err error)

BuildCommand assembles the final remote shell line: env exports, cd, sudo wrapping. Exposed so --dry-run can show exactly what would run.

func ForgetHost

func ForgetHost(addr string) (int, error)

ForgetHost removes known_hosts lines for addr (host:port normalised).

func KnownHostsPath

func KnownHostsPath() string

func Output

func Output(ctx context.Context, c *Client, cmd string, timeout time.Duration) (string, int, error)

Output is a convenience for internal probes: run and return trimmed stdout.

func ParseAdhoc

func ParseAdhoc(s string) (*store.Host, error)

ParseAdhoc parses user@host:port into a transient host.

func Q

func Q(s string) string

Q single-quotes s for POSIX sh.

func ScanHostKey

func ScanHostKey(ctx context.Context, addr string, timeout time.Duration) (ssh.PublicKey, error)

ScanHostKey fetches the server's host key without authenticating.

func TrustKey

func TrustKey(addr string, key ssh.PublicKey) error

Types

type Client

type Client struct {
	*ssh.Client
	Host *store.Host
	// contains filtered or unexported fields
}

Client wraps an ssh.Client plus the chain of jump clients that must be closed with it.

func Dial

func Dial(ctx context.Context, st *store.State, h *store.Host, o Options) (*Client, error)

Dial connects to h, honouring its jump chain.

func (*Client) Close

func (c *Client) Close() error

type Options

type Options struct {
	ConnectTimeout time.Duration
	HostKeyPolicy  string // accept-new | strict | off
}

type RunRequest

type RunRequest struct {
	Command   string
	Sudo      bool
	SudoUser  string
	Env       map[string]string
	Dir       string
	Stdin     []byte
	Timeout   time.Duration
	MaxOutput int
	PTY       bool
	// Stream, when set, receives output chunks as they arrive (follow mode).
	Stream func(stream string, chunk []byte)
}

type RunResult

type RunResult struct {
	ExitCode        int    `json:"exit_code"`
	Stdout          string `json:"stdout"`
	Stderr          string `json:"stderr"`
	StdoutTruncated bool   `json:"stdout_truncated,omitempty"`
	StderrTruncated bool   `json:"stderr_truncated,omitempty"`
	TimedOut        bool   `json:"timed_out,omitempty"`
	Signal          string `json:"signal,omitempty"`
	DurationMS      int64  `json:"duration_ms"`
}

func Run

func Run(ctx context.Context, c *Client, r RunRequest) (*RunResult, error)

Run executes a command and never returns an error for a non-zero exit: that is reported in RunResult.ExitCode. err is for transport failures.

Jump to

Keyboard shortcuts

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