Documentation
¶
Index ¶
Constants ¶
View Source
const SSHWorker = 10
SSHWorker 可以通过 gossh.SSHWorker 修改
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ExecResult ¶
type ExecResult struct {
ID int
Host string
Command string
LocalFilePath string
RemoteFilePath string
Result string
StartTime time.Time
EndTime time.Time
Error error
}
ExecResult 命令执行结果详情结构体
func LocalExec ¶
func LocalExec(cmd string, timeOutSecond int64) (ExecResult, error)
LocalExec 在本地执行命令,无需目标 host
type HostSession ¶
type HostSession struct {
Username string
Password string
Hostname string
Signers []ssh.Signer
Port int
Auths []ssh.AuthMethod
}
HostSession session 信息结构体
func (*HostSession) Exec ¶
func (exec *HostSession) Exec(id int, command string, config ssh.ClientConfig) *ExecResult
Exec execute the command and return a result structure
func (*HostSession) GenerateConfig ¶
func (exec *HostSession) GenerateConfig() ssh.ClientConfig
GenerateConfig 生成配置
func (*HostSession) Transfer ¶
func (exec *HostSession) Transfer(id int, localFilePath string, remoteFilePath string, config ssh.ClientConfig) *ExecResult
Transfer 使用 sftp 传输文件
type SSHExecAgent ¶
SSHExecAgent worker
func (*SSHExecAgent) SFTPHostByKey ¶
func (s *SSHExecAgent) SFTPHostByKey(hosts []string, port int, user string, localFilePath string, remoteFilePath string) ([]ExecResult, error)
SFTPHostByKey 通过 SFTP 协议传文件
func (*SSHExecAgent) SSHHostByKey ¶
func (s *SSHExecAgent) SSHHostByKey(hosts []string, port int, user string, cmd string) ([]ExecResult, error)
SSHHostByKey 通过 key 认证
Source Files
¶
- local_run.go
- remote_run.go
- session.go
- ssh.go
Click to show internal directories.
Click to hide internal directories.