ssh

package
v1.22.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package ssh is a simple wrapper around an ssh.Client which implements utilities to be performed with a remote server.

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 is a wrapper type over a ssh connection that takes care of creating a channel and running commands in a single method.

func (*Client) Close

func (sshc *Client) Close() error

Close closes the underlying connection.

func (*Client) DialContextF added in v1.17.0

func (sshc *Client) DialContextF() func(context.Context, string, string) (net.Conn, error)

DialContextF returns the underlying client's DialContext function

func (*Client) Download

func (sshc *Client) Download(src string, dst io.Writer, sudo bool) error

Download downloads a given src remote filepath to a given dst writer.

func (*Client) RunCommand

func (sshc *Client) RunCommand(cmd string) ([]byte, error)

RunCommand runs a given command in a new ssh session.

func (*Client) StartCommand

func (sshc *Client) StartCommand(cmd string) error

StartCommand starts a given command in a new ssh session. Unlike RunCommand this command does not wait command to finish. This is needed for running commands in the background.

func (*Client) Upload

func (sshc *Client) Upload(src io.Reader, dst string, sudo bool) ([]byte, error)

Upload uploads a given src object to a given destination file.

func (*Client) UploadFile

func (sshc *Client) UploadFile(src, dst string, sudo bool) ([]byte, error)

UploadFile uploads a given file path to a given destination file.

type ExtAgent

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

ExtAgent is a wrapper type over agent.ExtendedAgent provding a method to return a Client.

func NewAgent

func NewAgent() (*ExtAgent, error)

NewAgent connects to the local ssh agent and validates that it has at least one key added. It returns the agent if everything looks good.

func (*ExtAgent) NewClient

func (ea *ExtAgent) NewClient(ip string) (*Client, error)

NewClient returns a Client object by dialing the ssh agent on port 22

func (*ExtAgent) NewClientWithPort added in v1.17.0

func (ea *ExtAgent) NewClientWithPort(ip string, port string) (*Client, error)

NewClientWithPort returns a Client object by dialing the ssh agent on the provided port

Jump to

Keyboard shortcuts

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