ssh

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connect

func Connect(cfg ConnectConfig) (*ssh.Client, error)

Connect establishes an SSH connection.

func ResolveKeyPath

func ResolveKeyPath(keyName string) string

ResolveKeyPath returns the SSH private key path for a server's key name. Looks for ~/.ssh/conoha_<keyName>. Returns empty string if not found.

func RunCommand

func RunCommand(client *ssh.Client, command string, stdout, stderr io.Writer) (int, error)

RunCommand executes a single command on the remote server. Stdout/stderr are streamed to the provided writers. Returns the remote exit code.

func RunScript

func RunScript(client *ssh.Client, script []byte, env map[string]string, stdout, stderr io.Writer) (int, error)

RunScript uploads and executes a script on the remote server. Environment variables are exported before the script runs. Stdout/stderr are streamed to the provided writers. Returns the remote exit code.

NOTE: env keys must be validated with ValidateEnvKey before calling.

func RunWithStdin

func RunWithStdin(client *ssh.Client, command string, stdinData io.Reader, stdout, stderr io.Writer) (int, error)

RunWithStdin executes a command, piping stdinData to its stdin. Stdout/stderr are streamed to the provided writers. Returns the remote exit code.

func ServerIP

func ServerIP(s *model.Server) (string, error)

ServerIP extracts the best IPv4 address from server addresses. Prefers floating IPv4 over fixed IPv4, falls back to any IPv4.

func ValidateAppName

func ValidateAppName(name string) error

func ValidateEnvKey

func ValidateEnvKey(key string) error

Types

type ConnectConfig

type ConnectConfig struct {
	Host    string // IP or hostname
	Port    string // default "22"
	User    string // default "root"
	KeyPath string // path to private key file
}

ConnectConfig holds SSH connection parameters.

Jump to

Keyboard shortcuts

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