sshUtil

package
v1.0.3 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SFtpClient

func SFtpClient(c *ssh.Client) (*sftp.Client, error)

SFtpClient 创建一个SFTP客户端连接。 参数:

  • c: SSH客户端实例。

返回:

  • *sftp.Client: SFTP客户端实例。
  • error: 错误信息。

func SFtpDetectOS

func SFtpDetectOS(sftpClient *sftp.Client) string

SFtpDetectOS 检测远程主机的操作系统类型。 参数:

  • sftpClient: SFTP客户端实例。

返回:

  • string: 操作系统类型("linux"、"mac"、"Windows" 或 "unknown")。

func SFtpDownload

func SFtpDownload(sftpClient *sftp.Client, l, r string) error

SFtpDownload 从远程主机下载文件到本地。 参数:

  • sftpClient: SFTP客户端实例。
  • l: 本地文件路径。
  • r: 远程文件路径。

返回:

  • error: 错误信息。

func SFtpUpload

func SFtpUpload(sftpClient *sftp.Client, l, r string) error

SFtpUpload 上传本地文件到远程主机。 参数:

  • sftpClient: SFTP客户端实例。
  • l: 本地文件路径。
  • r: 远程文件路径。

返回:

  • error: 错误信息。

func SshClient

func SshClient(user, password, host string, port int) (*ssh.Client, error)

SshClient 创建一个SSH客户端连接。 参数:

  • user: 登录用户名,如果为空会提示输入。
  • password: 登录密码,如果为空会提示输入。
  • host: 目标主机地址。
  • port: 目标主机端口。

返回:

  • *ssh.Client: SSH客户端实例。
  • error: 错误信息。

func SshSession

func SshSession(c *ssh.Client) (*ssh.Session, error)

SshSession 创建一个SSH会话。 参数:

  • c: SSH客户端实例。

返回:

  • *ssh.Session: SSH会话实例。
  • error: 错误信息。

Types

This section is empty.

Jump to

Keyboard shortcuts

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