ssh

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2026 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EscapeArg

func EscapeArg(arg string) string

EscapeArg escapes a single argument for shell execution. This prevents shell injection by properly escaping special characters.

func EscapeArgs

func EscapeArgs(args []string) []string

EscapeArgs escapes multiple arguments for shell execution.

Types

type Config

type Config struct {
	Host string
	Port int
	User string
}

Config holds SSH connection configuration.

type Connector

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

Connector provides SSH connectivity functionality.

func New

func New(host string, port int, user string) *Connector

New creates a new SSH connector.

func (*Connector) BuildSCPArgs

func (c *Connector) BuildSCPArgs() []string

BuildSCPArgs builds SCP arguments for file transfer.

func (*Connector) BuildSSHArgs

func (c *Connector) BuildSSHArgs() []string

BuildSSHArgs builds common SSH arguments.

func (*Connector) CopyFile

func (c *Connector) CopyFile(ctx context.Context, localPath, remotePath string) error

CopyFile copies a local file to the remote host.

func (*Connector) CopyFileFromRemote

func (c *Connector) CopyFileFromRemote(ctx context.Context, remotePath, localPath string) error

CopyFileFromRemote copies a file from the remote host to local.

func (*Connector) ExecuteCommand

func (c *Connector) ExecuteCommand(ctx context.Context, command string) (string, error)

ExecuteCommand executes a command on the remote host.

func (*Connector) ExecuteCommandWithExitCode

func (c *Connector) ExecuteCommandWithExitCode(ctx context.Context, command string) (string, int, error)

ExecuteCommandWithExitCode executes a command and returns output with exit code.

func (*Connector) FileExists

func (c *Connector) FileExists(ctx context.Context, remotePath string) (bool, error)

FileExists checks if a file exists on the remote host.

func (*Connector) GetTarget

func (c *Connector) GetTarget() string

GetTarget returns the SSH target string.

func (*Connector) MakeExecutable

func (c *Connector) MakeExecutable(ctx context.Context, remotePath string) error

MakeExecutable makes a file executable on the remote host.

func (*Connector) RemoveFile

func (c *Connector) RemoveFile(ctx context.Context, remotePath string) error

RemoveFile removes a file on the remote host.

func (*Connector) TestConnection

func (c *Connector) TestConnection(ctx context.Context) error

TestConnection tests the SSH connection.

Jump to

Keyboard shortcuts

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