sshutils

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Reconnect

func Reconnect(cli *Cli) error

重联

Types

type Cli

type Cli struct {
	IP       string //IP地址
	Username string //用户名
	Password string //密码
	Port     int    //端口号

	SshClient *ssh.Client  //ssh客户端
	SftpCient *sftp.Client //sftp客户端
	// contains filtered or unexported fields
}

func NewCli

func NewCli(ip string, username string, password string, port ...int) (*Cli, error)

创建命令行对象 @param ip IP地址 @param username 用户名 @param password 密码 @param port 端口号,默认22

func (Cli) Download

func (cli Cli) Download(req SftpReq) []SftpRecord

使用sftp下载远程文件或文件夹到本地

func (Cli) Run

func (cli Cli) Run(command string) SshRecord

执行命令 注意:这个执行命令和go的os.exec一个尿性,不能获取到真实的错误信息,异常只能用于判断是否正确执行了你的命令

func (Cli) Upload

func (cli Cli) Upload(req SftpReq) []SftpRecord

使用sftp上传本地文件或文件夹到远程

type SftpRecord

type SftpRecord struct {
	LocalPath  string //本地路径
	RemotePath string //远程路径
	Err        error  //异常
}

type SftpReq

type SftpReq struct {
	LocalPath  string //本地路径
	RemotePath string //远程路径
	Overwrite  bool   // 覆盖
}

type SshRecord

type SshRecord struct {
	Command string //执行命令
	Result  string //执行结果
	Err     error  //异常
}

Jump to

Keyboard shortcuts

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