ssh

package
v0.0.7 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultKnownHostsPath

func DefaultKnownHostsPath() string

Types

type Client

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

Client 包装 ssh.Client,提供 DialContext 供 driver 使用。

func Connect

func Connect(ctx context.Context, opts Options) (*Client, *errors.XError)

Connect 建立 SSH 连接。

func (*Client) Close

func (c *Client) Close() error

Close 关闭 SSH 连接。

func (*Client) DialContext

func (c *Client) DialContext(ctx context.Context, network, addr string) (net.Conn, error)

DialContext 通过 SSH 通道建立到 target 的连接。

type Options

type Options struct {
	Host           string
	Port           int
	User           string
	IdentityFile   string // 私钥路径
	Passphrase     string // 私钥 passphrase(若有)
	KnownHostsFile string // 默认 ~/.ssh/known_hosts

	// SkipKnownHostsCheck 跳过 known_hosts 校验(极不推荐!)
	SkipKnownHostsCheck bool
}

Options 包含 SSH 连接所需参数。

Jump to

Keyboard shortcuts

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