ssh

package
v1.15.0 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cli

type Cli struct {
	Host       string       // 主机地址
	User       string       // 登录用户
	Password   string       // 密码
	Client     *ssh.Client  // bash操作
	SftpClient *sftp.Client // 文件操作
	LastResult string       // 执行的最后一次结果
	PrivateKey []byte       // 私钥串
	PublicKey  []byte       // 远程服务器的公钥串,如果有传则校验,可以不传
}

连接信息

func ConnectServer added in v1.15.0

func ConnectServer(cli Cli) (*Cli, error)

获取服务器操作对象

func Server

func Server(host string, user string, password string) (*Cli, error)

获取服务器操作对象,简单版本。

如果需要通过密钥连接,请使用 ConnectServer

func (*Cli) Close added in v1.10.0

func (c *Cli) Close()

关闭文件

func (*Cli) CombineRemoteFile added in v1.8.0

func (c *Cli) CombineRemoteFile(fileList []string, target string)

合并远程文件

fileList 文件列表

target 文件合成路径

func (*Cli) ConcatRemoteFile added in v1.10.0

func (c *Cli) ConcatRemoteFile(fileList []string, target string)

合并远程文件

func (*Cli) Connect

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

连接对象

func (*Cli) CreateFile added in v1.5.0

func (c *Cli) CreateFile(remoteFileName string) (*sftp.File, error)

创建文件

remoteFileName 文件名

func (*Cli) IsFileExist added in v1.5.0

func (c *Cli) IsFileExist(path string) bool

判断文件是否存在

func (Cli) Run

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

执行shellclient

func (Cli) RunQuiet added in v1.13.0

func (c Cli) RunQuiet(shell string) error

不需要输出信息

func (*Cli) SliceUpload added in v1.8.0

func (c *Cli) SliceUpload(target string, filePath string, num int) []string

切片本地文件上传到远程

target 服务器的目录

filePath 切片的文件路径

num 切片数量

func (*Cli) UploadDir added in v1.5.0

func (c *Cli) UploadDir(base string, target string)

上传目录到服务器

base 本地文件夹路径

target 远程文件夹路径

func (*Cli) UploadFile added in v1.5.0

func (c *Cli) UploadFile(localFile, remoteFileName string)

上传远程文件

localFile 本地文件路径

remoteFileName 远程文件路径

Jump to

Keyboard shortcuts

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