ssh

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2025 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GatherInventory

func GatherInventory(remote *ssh.Client) (*entity.Inventory, error)

Types

type ErrConnect

type ErrConnect struct {
	User   string
	Host   string
	Reason string
}

ErrConnect describes a connection error.

func (ErrConnect) Error

func (e ErrConnect) Error() string

Error returns a formatted string representation of the connection error.

type ErrInv

type ErrInv struct {
	User   string
	Host   string
	Reason string
}

ErrInv describes an inventory error.

func (ErrInv) Error

func (e ErrInv) Error() string

Error returns a formatted string representation of the inventory error.

type RemoteClient

type RemoteClient struct {
	ConnectOrder entity.ConnectOrder
	User         string
	Host         string
	Password     string

	Env   *entity.EnvList
	Color string

	Inventory *entity.Inventory
	// contains filtered or unexported fields
}

RemoteClient is a wrapper over the SSH connection/sessions.

func (*RemoteClient) Close

func (c *RemoteClient) Close() error

Close closes the underlying SSH connection and session.

func (*RemoteClient) Connect

func (c *RemoteClient) Connect(host entity.NetworkHost) error

Connect creates SSH connection to a specified host. It expects the host of the form "[ssh://]host[:port]".

func (*RemoteClient) ConnectWith

func (c *RemoteClient) ConnectWith(host entity.NetworkHost, dialer SSHDialFunc) error

ConnectWith creates a SSH connection to a specified host. It will use dialer to establish the connection. TODO: Split Signers to its own method.

func (*RemoteClient) DialThrough

func (c *RemoteClient) DialThrough(net, addr string, config *ssh.ClientConfig) (*ssh.Client, error)

DialThrough will create a new connection from the ssh server sc is connected to. DialThrough is an SSHDialer.

func (*RemoteClient) Download

func (c *RemoteClient) Download(remotePath, localPath string, silent bool) error

Download file from remote

func (*RemoteClient) FetchEnvsWithTar

func (c *RemoteClient) FetchEnvsWithTar() error

func (*RemoteClient) GenerateOnRemote

func (c *RemoteClient) GenerateOnRemote(data []byte, remotePath string) error

GenerateOnRemote basically cats file content to "~/" + entity.TASK_TAIL on remote

func (RemoteClient) GetConnection

func (c RemoteClient) GetConnection() *ssh.Client

GetConnection returns the client configuration of the SSHClient.

func (*RemoteClient) GetHost

func (c *RemoteClient) GetHost() string

GetHost returns the host of the SSHClient.

func (*RemoteClient) GetInventory

func (c *RemoteClient) GetInventory() *entity.Inventory

func (*RemoteClient) GetPassword

func (c *RemoteClient) GetPassword() string

GetPassword returns the password of the SSHClient.

func (RemoteClient) GetSSHConfig

func (c RemoteClient) GetSSHConfig() *ssh.ClientConfig

GetConnection returns the client configuration of the SSHClient.

func (*RemoteClient) GetShell

func (c *RemoteClient) GetShell() string

func (RemoteClient) GetTube

func (c RemoteClient) GetTube() string

GetTube returns the tube of the SSHClient.

func (*RemoteClient) Prefix

func (c *RemoteClient) Prefix() (string, int)

Prefix sets prefix for printing

func (*RemoteClient) Run

func (c *RemoteClient) Run(task *entity.Task) error

Run runs the task.Run command remotely on c.host.

func (*RemoteClient) SetConnection

func (c *RemoteClient) SetConnection(client *ssh.Client)

SetConnection sets the SSH client connection of the SSHClient.

func (*RemoteClient) SetPassword

func (c *RemoteClient) SetPassword(pwd string)

SetPassword sets the password of the SSHClient.

func (*RemoteClient) SetTube

func (c *RemoteClient) SetTube(name string)

SetTube sets the tube of the SSHClient.

func (*RemoteClient) Signal

func (c *RemoteClient) Signal(sig os.Signal) error

Signal process command signals

func (*RemoteClient) Stderr

func (c *RemoteClient) Stderr() io.Reader

Stderr sets remote stderr

func (*RemoteClient) Stdin

func (c *RemoteClient) Stdin() io.WriteCloser

Stdin sets remote stdin

func (*RemoteClient) Stdout

func (c *RemoteClient) Stdout() io.Reader

Stdout sets remote stdout

func (*RemoteClient) Upload

func (c *RemoteClient) Upload(localPath, remotePath string) error

Upload local file to remote server

func (*RemoteClient) Wait

func (c *RemoteClient) Wait() error

Wait waits until the remote command finishes and exits. It closes the SSH session.

func (*RemoteClient) Write

func (c *RemoteClient) Write(p []byte) (n int, err error)

func (*RemoteClient) WriteClose

func (c *RemoteClient) WriteClose() error

WriteClose well, writeCloser for client

type SSHDialFunc

type SSHDialFunc func(net, addr string, config *ssh.ClientConfig) (*ssh.Client, error)

SSHDialFunc can dial an ssh server and return a client

Jump to

Keyboard shortcuts

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