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
- Variables
- type Client
- func (c *Client) CopyTo(ctx context.Context, host, user, localPath, remotePath string) error
- func (c *Client) Run(ctx context.Context, host, user, cmd string) (stdout, stderr string, err error)
- func (c *Client) Stream(ctx context.Context, host, user, cmd string, stdout, stderr writer) error
- func (c *Client) StreamStdin(ctx context.Context, host, user, cmd string, stdin io.Reader, ...) error
Constants ¶
const DefaultDialTimeout = 30 * time.Second
DefaultDialTimeout is the TCP+SSH-handshake deadline applied when the caller's context has no deadline of its own.
const DefaultPort = "22"
DefaultPort is the standard ssh port. Used when host has no ":port" suffix.
Variables ¶
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
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 ¶
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