ssh

package
v0.4.13 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewClient

func NewClient(conn net.Conn, host string, port int, username string) (*ssh.Client, error)

func NewClientWithKey

func NewClientWithKey(conn net.Conn, host string, port int, username string, key, keyPassphrase string) (*ssh.Client, error)

func NewClientWithPassword

func NewClientWithPassword(conn net.Conn, host string, port int, username string, password string) (*ssh.Client, error)

func RemoveRemote

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

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

入参:

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

出参:

  • 错误。

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