sshexec

package
v0.0.0-...-d733991 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

README

sshexec - Go library for executing SSH commands

This is a simple Go library for starting an SSH client agent and executing a set of commands based on host and credentials in a concurrent manner and passing the results of that command execution to a set of listening functions.

Example usage can be found in the example directory.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ExecResult

type ExecResult struct {
	Id             uuid.UUID
	Host           string
	Command        string
	LocalFilePath  string
	RemoteFilePath string
	Result         string
	StartTime      time.Time
	EndTime        time.Time
	Error          error
}

type HostSession

type HostSession struct {
	Username string
	Password string
	Hostname string
	Signers  []ssh.Signer
	Port     int
	Auths    []ssh.AuthMethod
}

func (*HostSession) Exec

func (exec *HostSession) Exec(id uuid.UUID, command string, config ssh.ClientConfig) *ExecResult

func (*HostSession) GenerateConfig

func (exec *HostSession) GenerateConfig() ssh.ClientConfig

func (*HostSession) Transfer

func (exec *HostSession) Transfer(id uuid.UUID, localFilePath string, remoteFilePath string, config ssh.ClientConfig) *ExecResult

type SSHExecAgent

type SSHExecAgent struct {
	AllReturn []ExecResult
	// contains filtered or unexported fields
}

func NewAgent

func NewAgent() *SSHExecAgent

func (*SSHExecAgent) AddListener

func (agent *SSHExecAgent) AddListener(f func(*ExecResult))

func (*SSHExecAgent) RunWithCreds

func (agent *SSHExecAgent) RunWithCreds(username string, password string, authMethod []ssh.AuthMethod, hostname string, port int, command string) *uuid.UUID

func (*SSHExecAgent) RunWithSession

func (agent *SSHExecAgent) RunWithSession(session *HostSession, command string) *uuid.UUID

func (*SSHExecAgent) Start

func (agent *SSHExecAgent) Start()

func (*SSHExecAgent) Stop

func (agent *SSHExecAgent) Stop()

func (*SSHExecAgent) TransferWithCreds

func (agent *SSHExecAgent) TransferWithCreds(username string, password string, authMethod []ssh.AuthMethod, hostname string, port int, localFilePath string, remoteFilePath string) *uuid.UUID

func (*SSHExecAgent) TransferWithSession

func (agent *SSHExecAgent) TransferWithSession(session *HostSession, localFilePath string, remoteFilePath string) *uuid.UUID

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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