batchssh

package
v1.15.1 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// SuccessIdentifier for result output.
	SuccessIdentifier = "SUCCESS"
	// FailedIdentifier for result output.
	FailedIdentifier = "FAILED"
)
View Source
const (
	PushBeginFile      = "C"
	PushBeginFolder    = "D"
	PushBeginEndFolder = "0"
	PushEndFolder      = "E"
	PushEnd            = "\x00"
)

Variables

This section is empty.

Functions

func WithCommandTimeout

func WithCommandTimeout(timeout time.Duration) func(*Client)

WithCommandTimeout task connection timeout option.

func WithConcurrency

func WithConcurrency(count int) func(*Client)

WithConcurrency concurrency tasks number option.

func WithConnTimeout

func WithConnTimeout(timeout time.Duration) func(*Client)

WithConnTimeout ssh connection timeout option.

func WithProxyServer added in v1.0.0

func WithProxyServer(proxyServer, user string, port int, auths []ssh.AuthMethod) func(*Client)

WithProxyServer connect remote hosts by proxy server.

Types

type Client

type Client struct {
	ConnTimeout    time.Duration
	CommandTimeout time.Duration
	Concurrency    int
	Proxy          *Proxy
}

Client for ssh.

func NewClient

func NewClient(options ...func(*Client)) *Client

NewClient session.

func (*Client) BatchRun

func (c *Client) BatchRun(hosts []*Host, sshTask Tasker) <-chan *Result

BatchRun command on remote servers.

func (*Client) ExecuteCmd

func (c *Client) ExecuteCmd(host *Host, command, lang, runAs string, sudo bool) (string, error)

ExecuteCmd on remote host.

func (*Client) ExecuteScript

func (c *Client) ExecuteScript(
	host *Host,
	srcFile, dstDir, lang, runAs string,
	sudo, remove, allowOverwrite bool,
) (string, error)

ExecuteScript on remote host.

func (*Client) FetchFiles added in v1.4.0

func (c *Client) FetchFiles(
	host *Host,
	srcFiles []string,
	dstDir, tmpDir string,
	sudo bool,
	runAs string,
	enableZip bool,
	hostCount int,
) (string, error)

FetchFiles from remote host.

func (*Client) PushFiles added in v1.4.0

func (c *Client) PushFiles(
	host *Host,
	srcFiles, srcZipFiles []string,
	dstDir string,
	allowOverwrite, enableZip bool,
) (string, error)

PushFiles to remote host.

type Host added in v1.8.0

type Host struct {
	Alias      string
	Host       string
	Port       int
	User       string
	Password   string
	Keys       []string
	Passphrase string
	SSHAuths   []ssh.AuthMethod
}

Host target host.

type Proxy added in v1.0.0

type Proxy struct {
	SSHClient *ssh.Client
	Err       error
}

Proxy server.

type Result

type Result struct {
	Host    string `json:"host"`
	Status  string `json:"status"`
	Message string `json:"message"`
}

Result of ssh command.

type Tasker added in v1.15.0

type Tasker interface {
	SSH(host *Host) (string, error)
}

Tasker for ssh.

Jump to

Keyboard shortcuts

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