sshexec

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2025 License: Apache-2.0 Imports: 12 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.

Jump to

Keyboard shortcuts

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