ssh

package
v0.4.15 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RemoveRemote

func RemoveRemote(sshCli *ssh.Client, path string, useSCP bool) error

删除指定远程路径的文件。

入参:

  • sshCli: SSH 客户端。
  • path: 文件远程路径。
  • useSCP: 是否使用 SCP 进行传输,否则使用 SFTP。

出参:

  • 错误。

func RunCommand added in v0.4.15

func RunCommand(sshCli *ssh.Client, command string) (string, string, error)

执行远程脚本命令,并返回执行后标准输出和标准错误。

入参:

  • sshCli: SSH 客户端。
  • command: 待执行的脚本命令。

出参:

  • stdout:标准输出。
  • stderr:标准错误。
  • err: 错误。

func WriteRemote

func WriteRemote(sshCli *ssh.Client, path string, data []byte, useSCP bool) error

将数据写入指定远程路径的文件。 如果目录不存在,将会递归创建目录。 如果文件不存在,将会创建该文件;如果文件已存在,将会覆盖原有内容。

入参:

  • sshCli: SSH 客户端。
  • path: 文件远程路径。
  • data: 文件数据字节数组。
  • useSCP: 是否使用 SCP 进行传输,否则使用 SFTP。

出参:

  • 错误。

func WriteRemoteString

func WriteRemoteString(sshCli *ssh.Client, path string, content string, useSCP bool) error

WriteRemote 类似,但写入的是字符串内容。

入参:

  • sshCli: SSH 客户端。
  • path: 文件远程路径。
  • data: 文件数据字节数组。
  • useSCP: 是否使用 SCP 进行传输,否则使用 SFTP。

出参:

  • 错误。

Types

This section is empty.

Jump to

Keyboard shortcuts

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