ssh

package
v0.0.0-...-be40240 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2022 License: BSD-2-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Address

type Address struct {
	User string
	Addr string
}

Address is used to specify the user and address of the target machine.

func NewAddress

func NewAddress(user, addr string) Address

NewAddress is a constructor for an ssh address. If the addr does not contain a port (of the form "address:port"), it will add port 22 to the end of the addr.

type Client

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

func NewClient

func NewClient() (*Client, error)

NewClient is a the Client constructor. It connects to the running ssh-agent and sets up the user name. The user name can be overridden using the SSH_USER environment variable.

func (*Client) Close

func (c *Client) Close() error

Close releases the resources used by the Client.

func (*Client) Copy

func (c *Client) Copy(srcFile, destFile string) ([]byte, error)

Copy uses the scp protocol to copy the given srcfile from the local host to the destFile on the remote host. The scp protocol is explain here:

https://blogs.oracle.com/janp/entry/how_the_scp_protocol_works

The returned byte slice is the combined stout and stderr output from the command.

func (*Client) DirectConnect

func (c *Client) DirectConnect(addr Address) error

DirectConnect establishes an authenticated ssh connection to the given address. If the connection succeeds it will need to be closed.

func (*Client) JumpConnect

func (c *Client) JumpConnect(jumpAddr, remoteAddr Address) error

JumpConnect established an authenticated ssh connection via a jump host (aka bastion), meaning that this will first connect to the jump host, then connect to the remote address. If the connection succeeds it will need to be closed.

func (*Client) Run

func (c *Client) Run(cmd string) ([]byte, error)

Run executes the given command on the remote host. The returned byte slice is the combined stout and stderr output from the command.

func (*Client) Sudo

func (c *Client) Sudo(cmd string) ([]byte, error)

Sudo executes the given command on the remote host as a sudo command. The returned byte slice is the combined stout and stderr output from the command.

type ClientError

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

func (ClientError) Error

func (e ClientError) Error() string

Jump to

Keyboard shortcuts

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