sshexec

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connect

func Connect(user, host string, port int, sshKeyPath string) (*ssh.Client, error)

func Quote

func Quote(s string) string

Quote returns a shell-escaped version of the string s. The returned value is a string that can safely be used as one token in a shell command line.

func QuoteCommand

func QuoteCommand(args ...string) string

QuoteCommand returns a shell-escaped version of the command arguments. The returned value is a string that can safely be used as shell command arguments.

Types

type Executor

type Executor interface {
	Run(ctx context.Context, cmd string) (string, error)
	Stream(ctx context.Context, cmd string, stdout, stderr io.Writer) error
	Close() error
}

type Remote

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

func NewRemote

func NewRemote(client *ssh.Client) *Remote

func (*Remote) Close

func (r *Remote) Close() error

Close closes the connection to the remote host.

func (*Remote) Run

func (r *Remote) Run(ctx context.Context, cmd string) (string, error)

Run runs the command on the remote host and returns its output with all leading and trailing white space removed.

func (*Remote) Stream

func (r *Remote) Stream(ctx context.Context, cmd string, stdout, stderr io.Writer) error

Stream runs the command on the remote host and streams its output to the provided writers.

type SSHCLIRemote added in v0.15.0

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

func NewSSHCLIRemote added in v0.15.0

func NewSSHCLIRemote(user, host string, port int, keyPath string) *SSHCLIRemote

func (*SSHCLIRemote) Close added in v0.15.0

func (r *SSHCLIRemote) Close() error

no-op as there is no persistent connection.

func (*SSHCLIRemote) Run added in v0.15.0

func (r *SSHCLIRemote) Run(ctx context.Context, cmd string) (string, error)

func (*SSHCLIRemote) Stream added in v0.15.0

func (r *SSHCLIRemote) Stream(ctx context.Context, cmd string, stdout, stderr io.Writer) error

Jump to

Keyboard shortcuts

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