ssh

package
v0.0.0-...-deb4ee6 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2026 License: MIT Imports: 8 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 to a remote host.

func NewClient

func NewClient(cfg Config) (*Client, error)

NewClient establishes an SSH connection using the given config.

Key resolution order:

  1. PILOT_SSH_KEY env var — PEM content directly (CI/CD pipelines, GitHub Actions secrets)
  2. cfg.KeyPath file — local path, supports ~/ expansion

func (*Client) Close

func (c *Client) Close() error

Close terminates the SSH connection.

func (*Client) CopyFileTo

func (c *Client) CopyFileTo(ctx context.Context, localPath, remotePath string) error

CopyFileTo uploads a single local file to an exact remote path, creating parent directories as needed. Use this instead of CopyFiles when the remote path must differ from the basename (e.g. preserving relative directory structure: ./nginx/prod.conf → ~/pilot/nginx/prod.conf).

func (*Client) CopyFiles

func (c *Client) CopyFiles(ctx context.Context, localPaths []string, remoteDir string) error

CopyFiles uploads local files to a remote directory using SCP-over-SSH. All files land flat in remoteDir (basename only, no subdirectory structure).

func (*Client) Run

func (c *Client) Run(ctx context.Context, command string) (string, error)

Run executes a command on the remote host and returns combined output.

func (*Client) RunWithOutput

func (c *Client) RunWithOutput(ctx context.Context, command string, w io.Writer) error

RunWithOutput executes a command on the remote host and writes combined stdout+stderr to w in real time. Returns an error if the command exits non-zero. Unlike Run, the caller sees output as it arrives — useful for long-running commands such as docker pull or docker compose up.

func (*Client) Stream

func (c *Client) Stream(ctx context.Context, command string) (<-chan string, error)

Stream executes a command on the remote host and streams output line by line. The returned channel is closed when the command exits or ctx is cancelled.

type Config

type Config struct {
	Host    string
	User    string
	KeyPath string
	Port    int
}

Config holds the parameters for an SSH connection.

Jump to

Keyboard shortcuts

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