gtbox_ssh

package
v0.1.75 Latest Latest
Warning

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

Go to latest
Published: May 7, 2024 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Overview

Package gtbox_ssh SSH工具库

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GTSSHClientRun

func GTSSHClientRun(cliInfo *CLIConnectInfo, cmds []string, endFunc func(result *SSHResultInfo, err error))

GTSSHClientRun 对一个地址多个命令并发执行并返回

func GTSSHClientRunDualAddress

func GTSSHClientRunDualAddress(cliInfos []*CLIConnectInfo, cmds []string, endFunc func(results []*SSHResultInfo, err error))

GTSSHClientRunDualAddress 对多个地址多个命令并发执行并返回 使用

Types

type CLIConnectInfo

type CLIConnectInfo struct {
	Address   string       `json:"address"`
	Port      int64        `json:"port"`
	User      string       `json:"user"`
	Pwd       string       `json:"pwd"`
	LoginType SSHLoginType `json:"login_type"`
}

CLIConnectInfo 地址信息

type CmdResult

type CmdResult struct {
	Result string    `json:"Cmd_result"`
	Time   time.Time `json:"time"`
}

CmdResult 命令行返回值

type SSHController

type SSHController struct {
	Address     string
	Port        int64
	User        string
	Pwd         string       //如果login_type为证书登录pwd为私钥字符串
	LoginType   SSHLoginType `json:"login_type"`
	Client      *ssh.Client
	Session     *ssh.Session
	LastResult  string
	ConnectLock *sync.RWMutex
	RunCmdLock  *sync.RWMutex
}

SSHController 连接Detail信息 struct

func (*SSHController) Connect

func (c *SSHController) Connect() (*SSHController, error)

Connect 连接远端

func (SSHController) Run

func (c SSHController) Run(shell string) (string, error)

Run 执行shell

type SSHLoginType added in v0.0.42

type SSHLoginType int
const (
	SSHLoginTypePWD SSHLoginType = iota
	SSHLoginTypeCert
)

func (SSHLoginType) String added in v0.0.42

func (logT SSHLoginType) String() string

type SSHResultData

type SSHResultData struct {
	CmdResult  []*CmdResult `json:"cmd_result"`
	CmdStr     string       `json:"cmd_str"`
	ResultTime time.Time    `json:"result_time"`
}

SSHResultData 执行信息

type SSHResultInfo

type SSHResultInfo struct {
	Address    string           `json:"address"`
	Port       int64            `json:"port"`
	ResultData []*SSHResultData `json:"result_data"`
}

SSHResultInfo 返回信息Struct

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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