sshExecutor

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2023 License: MIT Imports: 13 Imported by: 0

README

ssh-executor

Lib for local&remote ssh connect&execution

import (
  sshExecutor "github.com/NGRsoftlab/ssh-executor"
)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCommandOutWithErr

func GetCommandOutWithErr(connParams ConnectParams, kill chan *os.Signal,
	timeoutConn, timeoutCmd time.Duration, command string) (output []byte, errOutput []byte, duration time.Duration, err error)

GetCommandOutWithErr get result command output (with errOut) from ssh connection

func GetSudoCommandsOutWithoutErr

func GetSudoCommandsOutWithoutErr(connParams ConnectParams,
	timeoutConn, timeoutCmd time.Duration, commands ...string) (output []byte, err error)

GetSudoCommandsOutWithoutErr get result sudo (!) commands... output from ssh connection

func LocalExecContext

func LocalExecContext(timeout time.Duration, command string, params ...string) (output []byte, err error)

LocalExecContext local execution command with context

func SendFileWithScp

func SendFileWithScp(connParams ConnectParams, kill chan *os.Signal,
	timeoutConn, timeoutCmd time.Duration, pathParams FilePathParams) (time.Duration, error)

SendFileWithScp get result command output (with errOut) from ssh connection

Types

type ConnectParams

type ConnectParams struct {
	Host string
	Port int
	User string
	Psw  string
}

ConnectParams params for ssh connection

type Connection

type Connection struct {
	*ssh.Client
	// contains filtered or unexported fields
}

Connection ssh connection struct

func GetSshConnection

func GetSshConnection(connParams ConnectParams, timeout time.Duration) (connection *Connection, err error)

GetSshConnection getting ssh connection

func (*Connection) SendOneCommandWithErrOut

func (conn *Connection) SendOneCommandWithErrOut(kill chan *os.Signal, command string) ([]byte, []byte, time.Duration, error)

SendOneCommandWithErrOut sending one command (no SUDO, with strErr output, with killChan)

func (*Connection) SendScpFile

func (conn *Connection) SendScpFile(kill chan *os.Signal, pathParams FilePathParams) (time.Duration, error)

SendScpFile sending file (content = file string content) to rootFolder/folderName/fileName with scp

func (*Connection) SendSudoCommandsWithoutErrOut

func (conn *Connection) SendSudoCommandsWithoutErrOut(commands ...string) ([]byte, error)

SendSudoCommandsWithoutErrOut sending many commands (may be with SUDO, without strErr output)

func (*Connection) SendSudoPassword

func (conn *Connection) SendSudoPassword(in io.WriteCloser, out io.Reader, output *[]byte)

SendSudoPassword checking for sudo password ask (with recovery, be careful)

type FilePathParams

type FilePathParams struct {
	RootFolder   string
	FolderName   string
	FolderRights string
	FileName     string
	FileRights   string
	Content      string
}

FilePathParams params for scp file sending

Jump to

Keyboard shortcuts

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