Documentation
¶
Overview ¶
Package ssh provides a thin SSH client and parallel fanout helper for the coolify init mesh-bootstrap commands.
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 implements Runner using the golang.org/x/crypto/ssh library. Keys must be unencrypted PEM files. NOTE: host-key verification is intentionally disabled in v1 (alpha). This is acceptable for a bootstrap tool in controlled environments and should be improved in a future release.
func NewClient ¶
NewClient loads the private key at keyPath and returns a Client ready to SSH into hosts. If passphrase is non-nil it is used to decrypt the key; pass nil for unencrypted keys.
func (*Client) Run ¶
func (c *Client) Run(ctx context.Context, host, user string, port int, cmd string) (string, string, error)
Run connects to host:port over SSH as user, executes cmd, and returns the combined stdout, stderr, and any error. The connection is closed when the command finishes or ctx is cancelled.
func (*Client) UploadFile ¶
func (c *Client) UploadFile(ctx context.Context, host, user string, port int, localPath, remotePath string, mode os.FileMode) error
UploadFile streams localPath to remotePath on host via a single SSH session. The write is atomic: data lands in <remote>.tmp.$PID first and is renamed on success.
type FileUploader ¶
type FileUploader interface {
UploadFile(ctx context.Context, host, user string, port int, localPath, remotePath string, mode os.FileMode) error
}
FileUploader streams a local file to a remote path via a single SSH session. Kept separate from Runner so existing Runner mocks stay valid.
type Runner ¶
type Runner interface {
Run(ctx context.Context, host, user string, port int, cmd string) (stdout, stderr string, err error)
}
Runner executes a shell command on a remote host and returns its stdout, stderr, and exit error. It is an interface so tests can inject a fake implementation without opening real SSH connections.
type ServerResult ¶
ServerResult holds the return value (or error) from running a function against a single server.
func ForEachServer ¶
func ForEachServer[T any]( ctx context.Context, hosts []string, concurrency int, fn func(ctx context.Context, host string) (T, error), ) []ServerResult[T]
ForEachServer runs fn concurrently on every host, honouring the concurrency limit. It always returns a result for every host (even on error) and never returns early — callers inspect each ServerResult.Err.