gossh

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2019 License: Apache-2.0 Imports: 21 Imported by: 1

README

gossh

execute shell scripts among multiple ssh servers

usage

$  uuidgen
6F948925-429E-4D2C-B551-C9C6D12E5062
$  gossh --pbe hello,word --password C9C6D12E5062
+---+-------+-----------------------------+
| # | PLAIN | ENCRYPTED                   |
+---+-------+-----------------------------+
| 1 | hello | {PBE}eiRMlsZPLikVYpZMcHicyg |
| 2 | word  | {PBE}lAHH0UfuqZ0YtV_5VE77uw |
+---+-------+-----------------------------+
$  gossh --pbe hello,word --password C9C6D12E5062
+---+-------+-----------------------------+
| # | PLAIN | ENCRYPTED                   |
+---+-------+-----------------------------+
| 1 | hello | {PBE}6RGab13x5WfzFP0NpA_suA |
| 2 | word  | {PBE}qmPJAysHSmnfQEK-a6JM0A |
+---+-------+-----------------------------+

$  gossh --ebp 6RGab13x5WfzFP0NpA_suA,qmPJAysHSmnfQEK-a6JM0A --password C9C6D12E5062
+---+------------------------+-------+
| # | ENCRYPTED              | PLAIN |
+---+------------------------+-------+
| 1 | 6RGab13x5WfzFP0NpA_suA | hello |
| 2 | qmPJAysHSmnfQEK-a6JM0A | word  |
+---+------------------------+-------+
$  gossh --ebp {PBE}eiRMlsZPLikVYpZMcHicyg,{PBE}lAHH0UfuqZ0YtV_5VE77uw --password C9C6D12E5062
+---+-----------------------------+-------+
| # | ENCRYPTED                   | PLAIN |
+---+-----------------------------+-------+
| 1 | {PBE}eiRMlsZPLikVYpZMcHicyg | hello |
| 2 | {PBE}lAHH0UfuqZ0YtV_5VE77uw | word  |
+---+-----------------------------+-------+

resources

  1. Bootstrap
  2. Bootstrap 4 Password Show Hide
  3. Tables
  4. Golang SSH Client: Multiple Commands, Crypto & Goexpect Examples
  5. bramvdbogaerde/go-scp
  6. golang 批量scp 远程传输文件
  7. PBEWithMD5AndDES in go
  8. like python-sh, for easy call shell with golang
  9. A scp client library written in Go. The remote server must have the scp command
  10. How the SCP protocol works
  11. Golang SFTP Client: Download File, Upload File Example
  12. package sftp
  13. sftp/example_test.go
  14. Golang Client Examples
  15. go语言使用sftp包上传文件和文件夹到远程服务器

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func JSONPretty

func JSONPretty(data interface{}) string

JSONPretty prettify the JSON encoding of data silently

func JSONPrettyE

func JSONPrettyE(data interface{}) (string, error)

JSONPrettyE prettify the JSON encoding of data

Types

type Cmd

type Cmd interface {
	// Parse parses the command.
	Parse()
	// ExecInHosts execute in specified hosts.
	ExecInHosts(gs *GoSSH) error
}

Cmd means the executable interface

type CmdExcResult

type CmdExcResult struct {
}

CmdExcResult means the detail exec result of cmd

type CmdGroup

type CmdGroup struct {
	Type    cmdtype.CmdType
	Cmds    []Cmd
	Results []CmdExcResult
	// contains filtered or unexported fields
}

CmdGroup represents the a group of structure of command line with same cmd type in config's cmds.

func (*CmdGroup) Exec

func (g *CmdGroup) Exec()

Exec executes the CmdGroup.

func (*CmdGroup) Parse

func (g *CmdGroup) Parse()

Parse parses the CmdGroup's data.

type Config

type Config struct {
	Vars  []string
	Hosts []string
	Cmds  []string
}

Config represents the structure of input toml file structure.

func (Config) Parse

func (c Config) Parse() GoSSH

Parse parses the flags or cnf files to GoSSH.

type Direction

type Direction int

Direction means scp upload or download

const (
	// UnknownDirection means unknown direction.
	UnknownDirection Direction = iota
	// UploadDirection means upload direction.
	UploadDirection
	// DownloadDirection means download direction.
	DownloadDirection
)

type GoSSH

type GoSSH struct {
	Vars      Vars
	Hosts     []*Host
	HostsMap  map[string]*Host
	CmdGroups []CmdGroup
	// contains filtered or unexported fields
}

GoSSH defines the structure of the whole cfg context.

func (*GoSSH) Close added in v0.1.1

func (g *GoSSH) Close()

Close closes gossh.

type Host

type Host struct {
	Name       string
	Addr       string
	User       string
	Password   string // empty when using public key
	Properties Vars
}

Host represents the structure of remote host information for ssh.

type LocalCmd

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

LocalCmd means local commands.

func (*LocalCmd) ExecInHosts

func (l *LocalCmd) ExecInHosts(_ *GoSSH) error

ExecInHosts execute in specified hosts.

func (*LocalCmd) Parse

func (l *LocalCmd) Parse()

Parse parses the local cmd

type SCPCmd

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

SCPCmd means commands for scp.

func (*SCPCmd) ExecInHosts

func (s *SCPCmd) ExecInHosts(gs *GoSSH) error

ExecInHosts execute in specified hosts.

func (SCPCmd) Parse

func (SCPCmd) Parse()

Parse parses SCPCmd.

type SSHCmd

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

SSHCmd means SSH command.

func (SSHCmd) ExecInHosts

func (s SSHCmd) ExecInHosts(gs *GoSSH) error

ExecInHosts execute in specified hosts.

func (SSHCmd) Parse

func (SSHCmd) Parse()

Parse parses command.

type Vars

type Vars map[string]string

Vars alias the map[string]string.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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