ssh

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client wraps an SSH connection with additional functionality

func NewClient

func NewClient(host string, port int, user string, keyPath string) (*Client, error)

NewClient creates a new SSH client

func (*Client) Close

func (c *Client) Close() error

Close closes the SSH connection

func (*Client) Connect

func (c *Client) Connect() error

Connect establishes the SSH connection with retry logic and optimized TCP settings

func (*Client) CopyDirectory

func (c *Client) CopyDirectory(localPath, remotePath string) error

CopyDirectory copies a directory from local to remote server

func (*Client) CopyFile

func (c *Client) CopyFile(localPath, remotePath string) error

CopyFile copies a file from local to remote server

func (*Client) CopyFileWithMode

func (c *Client) CopyFileWithMode(localPath, remotePath string, mode os.FileMode) error

CopyFileWithMode uploads a file to the remote server with specific permissions

func (*Client) CopyFromRemote

func (c *Client) CopyFromRemote(remotePath, localPath string) error

CopyFromRemote copies a file from remote to local

func (*Client) Execute

func (c *Client) Execute(cmd string) (string, error)

Execute runs a command on the remote server

func (*Client) ExecuteStream

func (c *Client) ExecuteStream(cmd string, stdout, stderr io.Writer) error

ExecuteStream runs a command and streams output in real-time

func (*Client) ExecuteWithContext

func (c *Client) ExecuteWithContext(ctx context.Context, cmd string) (string, error)

ExecuteWithContext runs a command with context support for cancellation

func (*Client) IsConnected

func (c *Client) IsConnected() bool

IsConnected checks if the client is connected

func (*Client) StartStream

func (c *Client) StartStream(cmd string) (*StreamingSession, error)

StartStream creates a new streaming session for long-running commands

func (*Client) UploadReader

func (c *Client) UploadReader(reader io.Reader, remotePath string, mode os.FileMode) error

UploadReader uploads content from a reader to a remote file

type MultiplexConfig

type MultiplexConfig struct {
	ControlPath    string
	ControlPersist time.Duration
	MaxSessions    int
}

MultiplexConfig holds multiplexing configuration

type Multiplexer

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

Multiplexer manages SSH connection multiplexing for improved performance

func NewMultiplexer

func NewMultiplexer() *Multiplexer

NewMultiplexer creates a new SSH multiplexer

func (*Multiplexer) Cleanup

func (m *Multiplexer) Cleanup()

Cleanup removes stale connections

func (*Multiplexer) CloseAll

func (m *Multiplexer) CloseAll()

CloseAll closes all multiplexed connections

func (*Multiplexer) GetConnection

func (m *Multiplexer) GetConnection(host string, port int, user string, sshKey string) (*MuxConnection, error)

GetConnection retrieves or creates a multiplexed connection

type MuxConnection

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

MuxConnection represents a multiplexed SSH connection

func (*MuxConnection) Close

func (c *MuxConnection) Close() error

Close closes the multiplexed connection

func (*MuxConnection) Execute

func (c *MuxConnection) Execute(command string) (string, error)

Execute runs a command using the multiplexed connection

func (*MuxConnection) IsHealthy

func (c *MuxConnection) IsHealthy() bool

IsHealthy checks if the multiplexed connection is still active

type Pool

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

Pool manages a pool of SSH connections

func NewPool

func NewPool() *Pool

NewPool creates a new SSH connection pool

func (*Pool) CloseAll

func (p *Pool) CloseAll() error

CloseAll closes all connections in the pool

func (*Pool) Get

func (p *Pool) Get(host string, port int, user string) *Client

Get retrieves a client from the pool

func (*Pool) GetOrCreate

func (p *Pool) GetOrCreate(host string, port int, user string, keyPath string) (*Client, error)

GetOrCreate gets an existing client from the pool or creates a new one

func (*Pool) Remove

func (p *Pool) Remove(host string, port int, user string) error

Remove removes a client from the pool and closes it

type StreamingSession

type StreamingSession struct {
	Stdout io.Reader
	Stderr io.Reader
	// contains filtered or unexported fields
}

StreamingSession represents a streaming SSH session

func (*StreamingSession) Close

func (s *StreamingSession) Close() error

Close closes the streaming session

Jump to

Keyboard shortcuts

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