Help us shape the future of Go! Take the 2026 Go Developer Survey

ssh

package
v0.131.0 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package ssh provides simple SSH operations for SoundTouch speakers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Host string
	User string
	// contains filtered or unexported fields
}

Client wraps an SSH client to perform operations on SoundTouch speakers.

func NewClient

func NewClient(host string) *Client

NewClient creates a new SSH client for the given host. The default user is "root".

func (*Client) Close added in v0.125.0

func (c *Client) Close() error

Close closes the persistent connection opened by Connect, if any. Safe to call even when Connect was never called (e.g. every Run/UploadContent call so far used its own one-off connection).

func (*Client) Connect added in v0.125.0

func (c *Client) Connect() error

Connect opens a persistent SSH connection reused by subsequent Run/UploadContent calls, instead of each dialing its own. Call Close when done with it. Idempotent — calling Connect again while already connected is a no-op. Skip this for a single (or a rare few) command — dialing once and reusing it is only worth the extra Close bookkeeping when several calls follow in quick succession.

func (*Client) ReadDir

func (c *Client) ReadDir(remotePath string) (map[string][]byte, error)

ReadDir downloads all regular files under remotePath, returning a map of absolute remote path → file content. Missing or unreadable files are skipped.

func (*Client) ReadFile

func (c *Client) ReadFile(remotePath string) ([]byte, error)

ReadFile downloads the content of a file on the remote host. An empty file that causes cat to exit non-zero (a firmware quirk on some devices) is returned as empty bytes rather than an error.

func (*Client) Run

func (c *Client) Run(command string) (string, error)

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

command MUST be a hardcoded shell literal or constructed entirely from internal, service-controlled values — never from user-supplied HTTP input.

func (*Client) UploadContent

func (c *Client) UploadContent(content []byte, remotePath string) error

UploadContent uploads the given content to a file on the remote host using stdin piping.

Jump to

Keyboard shortcuts

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