sshe

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

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

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

README

ExecFunc: SSH 🧑‍💻

This allows for executing nescript Cmds and Scripts on remote SSH targets.

There are some quirks when using the SSH ExecFunc:

  • Env vars can only be used if the SSH server allows for it (e.g. by having a wildcard AcceptEnv).
  • Scripts and subprocess spawned from commands will have access to the systems Env vars by default.
  • Metrics can not be obtained, specifically timing data as is possible with local script execution.

Example

target := "10.0.0.1:22"
config := &ssh.ClientConfig{
	User: "root",
	Auth: []ssh.AuthMethod{
		ssh.Password("password"),
  },
  HostKeyCallback: ssh.InsecureIgnoreHostKey(),
}
sshExecutor := sshe.Executor(target, config)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Executor

func Executor(target string, config *ssh.ClientConfig) nescript.ExecFunc

Executor provides an ExecFunc that will start the script/cmd process on an SSH target. The target must be provided in the form of ip:port along with the ssh client config, specifing factors such as HostKeyAuth and the Auth method. As executing a command over SSH must be done by passing a single string, this ExecFunc will convert the given cmd/script to a string, thus this will use the formatter associated with the cmd/script.

Types

type SSHProcess

type SSHProcess struct {
	// contains filtered or unexported fields
}

Process represents a single instance of the script running or completed on the local device.

func (*SSHProcess) Close

func (p *SSHProcess) Close()

func (*SSHProcess) Kill

func (p *SSHProcess) Kill() error

func (*SSHProcess) Result

func (p *SSHProcess) Result() (*nescript.Result, error)

func (*SSHProcess) Signal

func (p *SSHProcess) Signal(s os.Signal) error

func (*SSHProcess) Write

func (p *SSHProcess) Write(input string) error

Jump to

Keyboard shortcuts

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