utils

package
v0.0.0-...-df583fe Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2019 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Close

func Close(a *Client)

Close closes the connection

func ConvertYamlToJSON

func ConvertYamlToJSON(i interface{}) interface{}

ConvertYamlToJSON will return a json interface

func PasswordKey

func PasswordKey(username string, password string, keyCallBack ssh.HostKeyCallback) (ssh.ClientConfig, error)

PasswordKey uses username and password to authenticate with the server

func PrivateKey

func PrivateKey(username string, path string, keyCallBack ssh.HostKeyCallback) (ssh.ClientConfig, error)

PrivateKey Loads a private and public key from "path" and returns a SSH ClientConfig to authenticate with the server

func PrivateKeyWithPassphrase

func PrivateKeyWithPassphrase(username string, passpharase []byte, path string, keyCallBack ssh.HostKeyCallback) (ssh.ClientConfig, error)

PrivateKeyWithPassphrase Loads a private and public key from "path" having passphrase and returns a SSH ClientConfig to authenticate with the server

Types

type Client

type Client struct {
	// the host to connect to
	Host string

	// the client config to use
	ClientConfig *ssh.ClientConfig

	// stores the SSH session while the connection is running
	Session *ssh.Session

	// stores the SSH connection itself in order to close it after transfer
	Conn ssh.Conn

	// the clients waits for the given timeout until given up the connection
	Timeout time.Duration

	// *ssh.client for sftp
	Sshclient *ssh.Client
}

Client is our ssh client struct

func NewClient

func NewClient(host string, config *ssh.ClientConfig) Client

NewClient Returns a new scp.Client with provided host and ssh.clientConfig It has a default timeout of one minute.

func (*Client) Connect

func (a *Client) Connect() error

Connect to the remote SSH server, returns error if it couldn't establish a session to the SSH server

type ClientConfigurer

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

ClientConfigurer struct containing all the configuration options

func NewConfigurer

func NewConfigurer(host string, config *ssh.ClientConfig) *ClientConfigurer

NewConfigurer Creates a new client configurer. It takes the required parameters: the host and the ssh.ClientConfig and returns a configurer populated with the default values for the optional parameters.

These optional parameters can be set by using the methods provided on the ClientConfigurer struct.

func (*ClientConfigurer) ClientConfig

func (c *ClientConfigurer) ClientConfig(config *ssh.ClientConfig) *ClientConfigurer

ClientConfig Alters the ssh.ClientConfig

func (*ClientConfigurer) Create

func (c *ClientConfigurer) Create() Client

Create Builds a client with the configuration stored within the ClientConfigurer

func (*ClientConfigurer) Host

func (c *ClientConfigurer) Host(host string) *ClientConfigurer

Host Alters the host of the client connects to

func (*ClientConfigurer) Timeout

func (c *ClientConfigurer) Timeout(timeout time.Duration) *ClientConfigurer

Timeout Changes the connection timeout. Defaults to one minute

Jump to

Keyboard shortcuts

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