ssh

package
v1.33.1 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: MIT Imports: 19 Imported by: 1 module, 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Execute

func Execute(data map[string]any, opts ...Option) (map[string]any, error)

func Spec added in v1.30.0

func Spec() actionspec.Spec

Spec declares the ssh action. It keeps to no guard, as it does not check what it is about to do against one, so that a guard refuses it unless it is allowed by name. It cannot run without host, user and cmd, and password or key_file, to log in with.

Types

type Action

type Action struct {
	// contains filtered or unexported fields
}

func (*Action) Run

func (a *Action) Run(with map[string]any) (map[string]any, error)

Run runs the command in with over SSH. The password and key passphrase in with are hidden by the workflow runner, which learns them before the action starts and masks the records this action logs.

type Callback

type Callback struct {
	// contains filtered or unexported fields
}

type Option

type Option func(*Callback)

func WithAfter

func WithAfter(f func(result *Result)) Option

func WithBefore

func WithBefore(f func(host string, port int, user string, cmd string)) Option

func WithEnvRefused

func WithEnvRefused(f func(name string, err error)) Option

WithEnvRefused is called for each environment variable the server refuses to set, typically because sshd_config does not list it in AcceptEnv. The command still runs, without that variable.

type Req

type Req struct {
	Host            string            `map:"host" validate:"required"`
	Port            int               `map:"port"`
	User            string            `map:"user" validate:"required"`
	Cmd             string            `map:"cmd" validate:"required"`
	Password        string            `map:"password"`
	KeyFile         string            `map:"key_file"`
	KeyPassphrase   string            `map:"key_passphrase"`
	Timeout         string            `map:"timeout"`
	Workdir         string            `map:"workdir"`
	Env             map[string]string `map:"env"`
	StrictHostCheck bool              `map:"strict_host_check"`
	KnownHosts      string            `map:"known_hosts"`
	// contains filtered or unexported fields
}

func NewReq

func NewReq() *Req

func (*Req) Do

func (r *Req) Do() (re *Result, er error)

type Res

type Res struct {
	Code   int    `map:"code"`
	Stdout string `map:"stdout"`
	Stderr string `map:"stderr"`
	// TimedOut is true when the command was stopped at the timeout. Code is
	// then the status it exited with once signalled, or -1 when it did not
	// stop, and Stdout and Stderr hold what it wrote until then.
	TimedOut bool `map:"timed_out"`
}

type Result

type Result struct {
	Req    Req           `map:"req"`
	Res    Res           `map:"res"`
	RT     time.Duration `map:"rt"`
	Status int           `map:"status"`
}

Jump to

Keyboard shortcuts

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