ssh

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 28, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package ssh is the Go-SDK boundary for ssh and scp. Per the cli-guard SECURITY.md discipline, simple-API tools (ssh, scp, tailscale) talk to

Index

Constants

View Source
const DefaultDialTimeout = 30 * time.Second

DefaultDialTimeout is the TCP+SSH-handshake deadline applied when the caller's context has no deadline of its own.

View Source
const DefaultPort = "22"

DefaultPort is the standard ssh port. Used when host has no ":port" suffix.

Variables

View Source
var ErrNoAuth = errors.New("ssh: no authentication method available (ssh-agent unreachable and no key path). Recovery: run `ssh-add ~/.ssh/<key>` to load a key into the agent, or set ssh.key_path in coily config")

ErrNoAuth is returned when neither ssh-agent nor a private key file can supply a usable signer. Message names the recovery path per

View Source
var ErrNoKnownHosts = errors.New("ssh: cannot load known_hosts; refusing to dial without host-key verification")

ErrNoKnownHosts is returned when ~/.ssh/known_hosts cannot be read. Failing closed here is the point. ssh.InsecureIgnoreHostKey is never

Functions

This section is empty.

Types

type Client

type Client struct {
	// KeyPath is a path to a PEM-encoded private key. If empty, the
	// running ssh-agent (SSH_AUTH_SOCK) is used.
	KeyPath string

	// KnownHostsPath overrides ~/.ssh/known_hosts. Mainly for tests.
	KnownHostsPath string

	// DialTimeout overrides DefaultDialTimeout. Used only when the
	// caller's context has no deadline.
	DialTimeout time.Duration
}

Client is a configured ssh dialer. Build one per-process and reuse. Nil fields take their default values described on each field.

func (*Client) CopyTo

func (c *Client) CopyTo(ctx context.Context, host, user, localPath, remotePath string) error

CopyTo uploads localPath to remotePath on host as user, using SFTP over the same ssh transport as Run / Stream. Host-key verification and auth

func (*Client) Run

func (c *Client) Run(ctx context.Context, host, user, cmd string) (stdout, stderr string, err error)

Run opens a session on host as user, runs cmd, and returns its stdout and stderr. The remote command is passed as a single string to the

func (*Client) Stream

func (c *Client) Stream(ctx context.Context, host, user, cmd string, stdout, stderr writer) error

Stream runs cmd on host as user, streaming stdout/stderr to the supplied writers as bytes arrive. Useful for `journalctl -f` style

func (*Client) StreamStdin

func (c *Client) StreamStdin(ctx context.Context, host, user, cmd string, stdin io.Reader, stdout, stderr writer) error

StreamStdin is Stream with a stdin reader attached to the remote session. Used by `coily ssh deploy` to pipe a sudo password into a

Jump to

Keyboard shortcuts

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