remote

package
v0.0.22 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2026 License: GPL-3.0 Imports: 16 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEmptyUsername      = errors.New("empty username")
	ErrEmptyPassword      = errors.New("empty password")
	ErrEmptyAddress       = errors.New("empty hostname")
	ErrInvalidPort        = errors.New("invalid port")
	ErrMissingIPv6Bracket = errors.New("missing closing bracket for IPv6 address")
)

Host parsing errors

Functions

func ParseHostsFile added in v0.0.10

func ParseHostsFile(filename string) (map[string][]Host, error)

ParseHostsFile reads a YAML hosts file and parses it into a map of role to hosts. The YAML format is: <role>: ["user:pass@host:port", ...]

func ToUnixPath added in v0.0.9

func ToUnixPath(pathStr string) string

Types

type Host added in v0.0.9

type Host struct {
	User     string
	Password string
	Address  string
	Port     int
}

Host represents a remote server connection with authentication details.

func ParseHostLine added in v0.0.10

func ParseHostLine(line string) (Host, error)

type HostPool added in v0.0.9

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

HostPool manages a cache of Remote connections keyed by Host. It reuses existing connections to avoid redundant SSH/SFTP handshakes.

func NewHostPool added in v0.0.9

func NewHostPool() *HostPool

NewHostPool creates a new empty HostPool.

func (*HostPool) GetRemote added in v0.0.9

func (p *HostPool) GetRemote(host Host) (*Remote, error)

GetRemote returns a Remote connection for the given Host. If a connection already exists in the pool, it returns the cached one. Otherwise, it creates a new connection and caches it.

type Remote

type Remote struct {
	Hostname string
	Port     int
	Username string
	Password string
	Logger   zerolog.Logger
	// contains filtered or unexported fields
}

Remote represents a SSH/SFTP client for remote server operations

func New

func New(h Host) (*Remote, error)

New creates a new Remote instance and establishes connections

func (*Remote) Close

func (r *Remote) Close() error

Close closes the SSH and SFTP connections

func (*Remote) ExecuteCommand

func (r *Remote) ExecuteCommand(cmd string) (int, string, string, error)

ExecuteCommand executes a command on the remote host via SSH.

func (*Remote) UploadDir added in v0.0.10

func (r *Remote) UploadDir(localDir, remoteDir string) error

UploadDir uploads a local directory recursively to remote path with better error handling

func (*Remote) UploadFile

func (r *Remote) UploadFile(localPath, remotePath string) error

UploadFile uploads a local file to remote path with buffer optimization

Jump to

Keyboard shortcuts

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