ssh

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const AuthMethodPassword = "password"
View Source
const AuthMethodSSHKey = "ssh_key"

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthSpec

type AuthSpec struct {
	Method     string       `json:"authMethod" mapstructure:"authMethod"`
	PrivateKey SecretKeyRef `json:"privateKey" mapstructure:"privateKey"`
	Passphrase SecretKeyRef `json:"passphrase" mapstructure:"passphrase"`
	Password   SecretKeyRef `json:"password" mapstructure:"password"`
}

type Client

type Client struct {
	Host     string
	Port     int
	Username string

	// For key auth
	PrivateKey []byte
	Passphrase []byte

	// For password auth
	Password []byte
	// contains filtered or unexported fields
}

Client connects to an SSH server and runs commands. Supports either SSH key or password authentication.

func NewClientKey

func NewClientKey(host string, port int, username string, privateKey, passphrase []byte) *Client

func NewClientPassword

func NewClientPassword(host string, port int, username string, password []byte) *Client

func (*Client) Close

func (c *Client) Close() error

func (*Client) Connect

func (c *Client) Connect() (*ssh.Client, error)

func (*Client) ExecuteCommand

func (c *Client) ExecuteCommand(command string, timeout time.Duration) (*CommandResult, error)

type CommandResult

type CommandResult struct {
	Stdout   string `json:"stdout"`
	Stderr   string `json:"stderr"`
	ExitCode int    `json:"exitCode"`
}

type ConnectionRetrySpec added in v0.8.0

type ConnectionRetrySpec struct {
	Enabled         bool `json:"enabled" mapstructure:"enabled"`
	Retries         int  `json:"retries" mapstructure:"retries"`
	IntervalSeconds int  `json:"intervalSeconds" mapstructure:"intervalSeconds"`
}

type ConnectionRetryState added in v0.8.0

type ConnectionRetryState struct {
	Attempt         int `json:"attempt" mapstructure:"attempt"`                 // retries done so far (1 = first retry)
	MaxRetries      int `json:"maxRetries" mapstructure:"maxRetries"`           // max retries from config
	IntervalSeconds int `json:"intervalSeconds" mapstructure:"intervalSeconds"` // seconds between attempts
}

type ExecuteSSHContext added in v0.8.0

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

type ExecutionMetadata

type ExecutionMetadata struct {
	Result           *CommandResult       `json:"result" mapstructure:"result"`
	Host             string               `json:"host" mapstructure:"host"`
	Port             int                  `json:"port" mapstructure:"port"`
	User             string               `json:"user" mapstructure:"user"`
	Command          string               `json:"command" mapstructure:"command"`
	WorkingDirectory string               `json:"workingDirectory" mapstructure:"workingDirectory"`
	Timeout          int                  `json:"timeout" mapstructure:"timeout"`
	ConnectionRetry  *ConnectionRetrySpec `json:"connectionRetry" mapstructure:"connectionRetry"`
	Attempt          int                  `json:"attempt" mapstructure:"attempt"`
	MaxRetries       int                  `json:"maxRetries" mapstructure:"maxRetries"`
	IntervalSeconds  int                  `json:"intervalSeconds" mapstructure:"intervalSeconds"`
	Authentication   AuthSpec             `json:"authentication" mapstructure:"authentication"`
}

type SSHCommand

type SSHCommand struct{}

func (*SSHCommand) Actions

func (c *SSHCommand) Actions() []core.Action

func (*SSHCommand) Cancel

func (c *SSHCommand) Cancel(ctx core.ExecutionContext) error

func (*SSHCommand) Cleanup

func (c *SSHCommand) Cleanup(ctx core.SetupContext) error

func (*SSHCommand) Color

func (c *SSHCommand) Color() string

func (*SSHCommand) Configuration

func (c *SSHCommand) Configuration() []configuration.Field

func (*SSHCommand) Description

func (c *SSHCommand) Description() string

func (*SSHCommand) Documentation

func (c *SSHCommand) Documentation() string

func (*SSHCommand) ExampleOutput

func (c *SSHCommand) ExampleOutput() map[string]any

func (*SSHCommand) Execute

func (c *SSHCommand) Execute(ctx core.ExecutionContext) error

func (*SSHCommand) HandleAction

func (c *SSHCommand) HandleAction(ctx core.ActionContext) error

func (*SSHCommand) HandleWebhook

func (c *SSHCommand) HandleWebhook(ctx core.WebhookRequestContext) (int, error)

func (*SSHCommand) Icon

func (c *SSHCommand) Icon() string

func (*SSHCommand) Label

func (c *SSHCommand) Label() string

func (*SSHCommand) Name

func (c *SSHCommand) Name() string

func (*SSHCommand) OutputChannels

func (c *SSHCommand) OutputChannels(configuration any) []core.OutputChannel

func (*SSHCommand) ProcessQueueItem

func (c *SSHCommand) ProcessQueueItem(ctx core.ProcessQueueContext) (*uuid.UUID, error)

func (*SSHCommand) Setup

func (c *SSHCommand) Setup(ctx core.SetupContext) error

type SecretKeyRef

type SecretKeyRef struct {
	Secret string `json:"secret" mapstructure:"secret"`
	Key    string `json:"key" mapstructure:"key"`
}

func (SecretKeyRef) IsSet

func (r SecretKeyRef) IsSet() bool

type Spec

type Spec struct {
	Host             string               `json:"host" mapstructure:"host"`
	Port             int                  `json:"port" mapstructure:"port"`
	User             string               `json:"username" mapstructure:"username"`
	Authentication   AuthSpec             `json:"authentication" mapstructure:"authentication"`
	Command          string               `json:"command" mapstructure:"command"`
	WorkingDirectory string               `json:"workingDirectory,omitempty" mapstructure:"workingDirectory"`
	Timeout          int                  `json:"timeout" mapstructure:"timeout"`
	ConnectionRetry  *ConnectionRetrySpec `json:"connectionRetry,omitempty" mapstructure:"connectionRetry"`
}

Jump to

Keyboard shortcuts

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