ssh

package
v29.0.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2025 License: Apache-2.0 Imports: 4 Imported by: 95

Documentation

Overview

Package ssh provides the connection helper for ssh:// URL.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Spec

type Spec struct {
	User string
	Host string
	Port string
	Path string
}

Spec of SSH URL

func NewSpec

func NewSpec(sshURL *url.URL) (*Spec, error)

NewSpec creates a Spec from the given ssh URL's properties. It returns an error if the URL is using the wrong scheme, contains fragments, query-parameters, or contains a password.

func ParseURL

func ParseURL(daemonURL string) (*Spec, error)

ParseURL creates a Spec from the given ssh URL. It returns an error if the URL is using the wrong scheme, contains fragments, query-parameters, or contains a password.

func (*Spec) Args

func (sp *Spec) Args(remoteCommandAndArgs ...string) []string

Args returns args except "ssh" itself combined with optional additional command and args to be executed on the remote host. It attempts to quote the given arguments to account for ssh executing the remote command in a shell. It returns nil when unable to quote the remote command.

func (*Spec) Command

func (sp *Spec) Command(sshFlags []string, remoteCommandAndArgs ...string) ([]string, error)

Command returns the ssh flags and arguments to execute a command (remoteCommandAndArgs) on the remote host. Where needed, it quotes values passed in remoteCommandAndArgs to account for ssh executing the remote command in a shell. It returns an error if no remote command is passed, or when unable to quote the remote command.

Important: to preserve backward-compatibility, Command does not currently perform sanitization or quoting on the sshFlags and callers are expected to sanitize this argument.

Jump to

Keyboard shortcuts

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