remote

package
v0.7.4 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: Apache-2.0 Imports: 17 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func QuotePOSIXShellArg

func QuotePOSIXShellArg(value string) string

QuotePOSIXShellArg 将单个值安全编码为 POSIX shell 参数。

Types

type Executor

type Executor struct {
	// contains filtered or unexported fields
}

Executor 封装通用 SSH 认证、远端命令执行和受限临时文件传输。

func NewExecutor

func NewExecutor(sshConfig *config.SSHConfig, purpose, tempPrefix string, knownHostsFiles ...string) (*Executor, error)

NewExecutor 建立支持密码或私钥认证并带 TOFU 主机密钥校验的 SSH 连接。

func NewExecutorContext

func NewExecutorContext(ctx context.Context, sshConfig *config.SSHConfig, purpose, tempPrefix string, knownHostsFiles ...string) (*Executor, error)

NewExecutorContext 建立可由调用方取消的 SSH 连接。

func (*Executor) Close

func (executor *Executor) Close()

Close 关闭 SSH 客户端连接。

func (*Executor) CreateTempDir

func (executor *Executor) CreateTempDir() (string, error)

CreateTempDir 在远端创建仅 SSH 用户可读写的业务专用临时目录。

func (*Executor) CreateTempDirContext

func (executor *Executor) CreateTempDirContext(ctx context.Context) (string, error)

CreateTempDirContext 在远端创建临时目录并响应调用方取消。

func (*Executor) IsRoot

func (executor *Executor) IsRoot() bool

IsRoot 返回当前 SSH 会话是否使用 root 用户。

func (*Executor) RemoveTempDir

func (executor *Executor) RemoveTempDir(tempDir string) error

RemoveTempDir 清理经过固定前缀校验的 SSH 临时目录。

func (*Executor) RemoveTempDirContext

func (executor *Executor) RemoveTempDirContext(ctx context.Context, tempDir string) error

RemoveTempDirContext 清理经过固定前缀校验的远端临时目录。

func (*Executor) Run

func (executor *Executor) Run(command string, input []byte, privileged bool) ([]byte, error)

Run 执行单条 SSH 命令;非 root 会话的特权命令自动通过 sudo 提权。

func (*Executor) RunContext

func (executor *Executor) RunContext(ctx context.Context, command string, input []byte, privileged bool) ([]byte, error)

RunContext 执行 SSH 命令,并在取消或硬超时后关闭会话并等待其退出。

func (*Executor) Upload

func (executor *Executor) Upload(remoteFile string, content []byte) error

Upload 通过 SSH 标准输入将敏感文件写入远端受限临时目录。

func (*Executor) UploadContext

func (executor *Executor) UploadContext(ctx context.Context, remoteFile string, content []byte) error

UploadContext 通过 SSH 标准输入写入文件并响应调用方取消。

Jump to

Keyboard shortcuts

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