sshutil

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CommandResult

type CommandResult struct {
	Stdout   string
	Stderr   string
	ExitCode int
	Error    error
}

type SSHClient

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

func NewSSHClient

func NewSSHClient(config *SSHConfig) (*SSHClient, error)

func (*SSHClient) Close

func (s *SSHClient) Close() error

Close 关闭SSH连接

func (*SSHClient) Ping

func (s *SSHClient) Ping() error

func (*SSHClient) RunCommand

func (s *SSHClient) RunCommand(cmd string) (*CommandResult, error)

RunCommand 执行单个命令

func (*SSHClient) RunCommands

func (s *SSHClient) RunCommands(commands []string) ([]*CommandResult, error)

func (*SSHClient) UploadDir

func (s *SSHClient) UploadDir(localDir, remoteDir string, ug string) error

UploadDir 上传文件夹到远程服务器

func (*SSHClient) UploadFile

func (s *SSHClient) UploadFile(localPath, remotePath string, mode string) error

UploadFile 上传文件到远程服务器

type SSHConfig

type SSHConfig struct {
	Host       string        // 主机地址
	Port       int           // 端口
	Username   string        // 用户名
	Password   string        // 密码
	PrivateKey string        // 私钥路径(如果使用密钥认证)
	Timeout    time.Duration // 连接超时时间
}

Jump to

Keyboard shortcuts

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