ssh

package
v0.0.0-...-73fa917 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2024 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrConnect

type ErrConnect struct {
	User   string
	Host   string
	Reason string
}

ErrConnect describes connection error

func (ErrConnect) Error

func (e ErrConnect) Error() string

type SSHClient

type SSHClient struct {
	User     string
	Host     string
	Password string

	Env       *entity.EnvList
	Color     string
	RcloneCfg string
	// contains filtered or unexported fields
}

SSHClient is a wrapper over the SSH connection/sessions.

func (*SSHClient) Close

func (c *SSHClient) Close() error

Close closes the underlying SSH connection and session.

func (*SSHClient) Connect

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

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

func (*SSHClient) ConnectWith

func (c *SSHClient) 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 (*SSHClient) DialThrough

func (c *SSHClient) 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 (*SSHClient) Download

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

Download file from remote

func (*SSHClient) GenerateOnRemote

func (c *SSHClient) GenerateOnRemote(data []byte) error

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

func (*SSHClient) GetHost

func (c *SSHClient) GetHost() string

func (SSHClient) GetTube

func (c SSHClient) GetTube() string

func (*SSHClient) Prefix

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

Prefix sets prefix for printing

func (*SSHClient) Run

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

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

func (*SSHClient) SetRcloneCfg

func (c *SSHClient) SetRcloneCfg(config string)

func (*SSHClient) SetTube

func (c *SSHClient) SetTube(name string)

func (*SSHClient) Signal

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

Signal process command signals

func (*SSHClient) Stderr

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

Stderr sets remote stderr

func (*SSHClient) Stdin

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

Stdin sets remote stdin

func (*SSHClient) Stdout

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

Stdout sets remote stdout

func (*SSHClient) Upload

func (c *SSHClient) Upload(localPath, remotePath string, config string) error

Upload local file to remote server

func (*SSHClient) Wait

func (c *SSHClient) Wait() error

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

func (*SSHClient) Write

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

func (*SSHClient) WriteClose

func (c *SSHClient) 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