ssh

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthError

type AuthError struct {
	Host string
	Err  error
}

AuthError indicates an authentication failure.

func (*AuthError) Error

func (e *AuthError) Error() string

func (*AuthError) Unwrap

func (e *AuthError) Unwrap() error

type CmdError

type CmdError struct {
	Host    string
	Command string
	Output  string
	Err     error
}

CmdError indicates a command execution failure.

func (*CmdError) Error

func (e *CmdError) Error() string

func (*CmdError) Unwrap

func (e *CmdError) Unwrap() error

type ConnError

type ConnError struct {
	Host string
	Addr string
	Err  error
}

ConnError indicates a connection failure.

func (*ConnError) Error

func (e *ConnError) Error() string

func (*ConnError) Unwrap

func (e *ConnError) Unwrap() error

type Executor

type Executor interface {
	Run(ctx context.Context, instance config.ServerInstance, command string) (string, error)
	RunWithSudo(ctx context.Context, instance config.ServerInstance, command string) (string, error)
	RunWithSudoAndStdin(ctx context.Context, instance config.ServerInstance, command string, stdinContent string) (string, error)
	Close() error
}

Executor defines the interface for running commands on remote servers.

type MockExecutor

type MockExecutor struct {
	RunFunc                 func(ctx context.Context, instance config.ServerInstance, command string) (string, error)
	RunWithSudoFunc         func(ctx context.Context, instance config.ServerInstance, command string) (string, error)
	RunWithSudoAndStdinFunc func(ctx context.Context, instance config.ServerInstance, command string, stdinContent string) (string, error)
	Closed                  bool
}

MockExecutor implements Executor for testing.

func (*MockExecutor) Close

func (m *MockExecutor) Close() error

func (*MockExecutor) Run

func (m *MockExecutor) Run(ctx context.Context, instance config.ServerInstance, command string) (string, error)

func (*MockExecutor) RunWithSudo

func (m *MockExecutor) RunWithSudo(ctx context.Context, instance config.ServerInstance, command string) (string, error)

func (*MockExecutor) RunWithSudoAndStdin

func (m *MockExecutor) RunWithSudoAndStdin(ctx context.Context, instance config.ServerInstance, command string, stdinContent string) (string, error)

type SSHClient

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

SSHClient implements Executor using native Go SSH.

func NewSSHClient

func NewSSHClient() (*SSHClient, error)

NewSSHClient creates a new SSH client with key loading from SSH agent and PPK_NAMES.

func (*SSHClient) Close

func (c *SSHClient) Close() error

func (*SSHClient) Run

func (c *SSHClient) Run(ctx context.Context, instance config.ServerInstance, command string) (string, error)

func (*SSHClient) RunWithSudo

func (c *SSHClient) RunWithSudo(ctx context.Context, instance config.ServerInstance, command string) (string, error)

func (*SSHClient) RunWithSudoAndStdin

func (c *SSHClient) RunWithSudoAndStdin(ctx context.Context, instance config.ServerInstance, command string, stdinContent string) (string, error)

Jump to

Keyboard shortcuts

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