goremoter

package module
v0.0.0-...-f586aae Latest Latest
Warning

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

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

README

goremoter

Remote SSH deploy tool written by golang

Execute commands on remote virtual-machine.

Implement based on module "golang.org/x/crypto/ssh",

add context.context for stop anytime.

Others / 其他同类别的各种语言的第三方件

[JavaScript] A lightweight JS library the runs an arbitrary series of shell commands on both local and remote hosts.

https://github.com/jerkeeler/rcktship

[Python] Sultan: Command and Rule over your Shell

https://github.com/aeroxis/sultan

[Golang] 这个库依旧不支持 context.Context。封装的太多了。

https://github.com/cosiner/socker

[Golang] 把 shell 命令解析为数据结构,然后执行这个数据结构,这个比较工作量大

https://github.com/mvdan/sh

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithPrefix

func WithPrefix(prefix string, remoter *Remoter) *pathPrefix

WithPrefix return the PathPrefix

Types

type Remoter

type Remoter struct {
	Host string
	User string
	Port string
	// contains filtered or unexported fields
}

func Dial

func Dial(waitCtx context.Context, sshConf map[string]interface{}) (*Remoter, error)

Dial remote machine sshConf["host"] = "1.1.1.1" sshConf["auth"] = []ssh.AuthMethod sshConf["port"] = sshConf["user"] =

func (*Remoter) Close

func (r *Remoter) Close() error

Close the ssn client

func (*Remoter) Get

func (r *Remoter) Get(waitCtx context.Context, remote string, local string) error

Get remote file to local, remove local file first in case of exists

func (*Remoter) Output

func (r *Remoter) Output(waitCtx context.Context, cmd string) (string, []byte, error)

Output run a command, and return stdout && stderr Also return the executed command, when cmd is compose by prefix, we need know cmd in caller

func (*Remoter) Put

func (r *Remoter) Put(waitCtx context.Context, local string, remote string) error

Put local file to remote, remove remote first in case of exists

func (*Remoter) Run

func (r *Remoter) Run(waitCtx context.Context, cmds []string, stdout io.Writer, stderr io.Writer) error

Run commands command not terminate by '\n' , commands not include "exit" If a middle command fails, the next command will run ignore error diff with Output() method, all command share one same stdout

Jump to

Keyboard shortcuts

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