ssh

package
v0.25.0 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2021 License: BSD-3-Clause Imports: 14 Imported by: 1

Documentation

Overview

Package ssh provide a wrapper for golang.org/x/crypto/ssh and a parser for SSH client configuration specification ssh_config(5).

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 for SSH connection.

func NewClient

func NewClient(cfg *ConfigSection) (cl *Client, err error)

NewClient create a new SSH connection using predefined configuration.

func (*Client) Execute

func (cl *Client) Execute(cmd string) (err error)

Execute a command on remote server.

func (*Client) Get

func (cl *Client) Get(remote, local string) (err error)

Get copy file from remote into local storage.

The local file should be use the absolute path, or relative to the file in ConfigSection's workingDir.

func (*Client) Put

func (cl *Client) Put(local, remote string) (err error)

Put copy a file from local storage to remote using scp command.

The local file should be use the absolute path, or relative to the file in ConfigSection's workingDir.

func (*Client) String

func (cl *Client) String() string

type Config added in v0.15.0

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

Config contains mapping of host's patterns and its options from SSH configuration file.

func NewConfig added in v0.15.0

func NewConfig(file string) (cfg *Config, err error)

NewConfig load SSH configuration from file.

func (*Config) Get added in v0.15.0

func (cfg *Config) Get(s string) (section *ConfigSection)

Get the Host or Match configuration that match with the pattern "s".

func (*Config) Prepend added in v0.15.0

func (cfg *Config) Prepend(other *Config)

Prepend other Config's sections to this Config. The other's sections will be at the top of the list.

This function can be useful if we want to load another SSH config file without using Include directive.

type ConfigSection added in v0.15.0

type ConfigSection struct {
	AddKeysToAgent              string
	AddressFamily               string
	BindAddress                 string
	BindInterface               string
	CanonicalDomains            []string
	CanonicalizeHostname        string
	CanonicalizeMaxDots         int
	CanonicalizePermittedCNAMEs *PermittedCNAMEs
	CASignatureAlgorithms       []string
	CertificateFile             []string
	ConnectionAttempts          int
	ConnectTimeout              int

	// Environments contains system environment variables that will be
	// passed to Execute().
	// The key and value is derived from "SendEnv" and "SetEnv".
	Environments map[string]string

	Hostname                          string
	IdentityFile                      []string
	Port                              int
	User                              string
	XAuthLocation                     string
	IsBatchMode                       bool
	IsCanonicalizeFallbackLocal       bool
	IsChallengeResponseAuthentication bool
	IsCheckHostIP                     bool
	IsClearAllForwardings             bool
	UseCompression                    bool
	UseVisualHostKey                  bool
	// contains filtered or unexported fields
}

ConfigSection is the type that represent SSH client Host and Match section in configuration.

type PermittedCNAMEs added in v0.15.0

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

Jump to

Keyboard shortcuts

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