ssh

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2026 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package ssh provides SSH connectivity utilities for remote server automation. It wraps github.com/sfreiberg/simplessh with a simplified API for playbook-style operations where you connect, run commands, and disconnect.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PrivateKeyPath

func PrivateKeyPath(sshKey string) string

PrivateKeyPath constructs the absolute path to an SSH private key file. It combines the current user's home directory with the .ssh directory and the provided key filename.

func RunOnce

func RunOnce(host, port, user, key, cmd string) (string, error)

RunOnce is a convenience function that connects, runs a command, and closes. Use this for single commands where you don't need to maintain the connection. The host parameter should be just the hostname, port is the SSH port (empty defaults to 22).

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client wraps an SSH connection with convenient methods for running commands.

func NewClient

func NewClient(host, port, user, key string) *Client

NewClient creates a new SSH client configuration. The host parameter should be just the hostname or IP (e.g., "db3.sinevia.com"). The port parameter is the SSH port (e.g., "22" or "40022"). The key parameter is just the filename (e.g., "2024_sinevia.prv"), which gets resolved to ~/.ssh/<key>.

func (*Client) Close

func (c *Client) Close() error

Close closes the SSH connection.

func (*Client) Connect

func (c *Client) Connect() error

Connect establishes the SSH connection. Must be called before Run or Close.

func (*Client) Run

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

Run executes a command on the remote server. Returns combined stdout/stderr output and any error.

Jump to

Keyboard shortcuts

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