Documentation
¶
Index ¶
- func StartKeepAlive(client *ssh.Client, interval time.Duration, fallback func(err error))
- type AuthMethod
- type Client
- func (c *Client) Close() error
- func (c *Client) Node() models.Node
- func (c *Client) Run(ctx context.Context, cmd string) (string, error)
- func (c *Client) RunScript(ctx context.Context, scriptContent string) (string, error)
- func (c *Client) RunScriptWithSudo(ctx context.Context, scriptContent string) (string, error)
- func (c *Client) RunWithSudo(ctx context.Context, command string) (string, error)
- func (c *Client) RunWithoutLogin(ctx context.Context, cmd string) (string, error)
- func (c *Client) SSHClient() *ssh.Client
- func (c *Client) Shell(ctx context.Context) error
- func (c *Client) ShellWithSudo(ctx context.Context) error
- type Connector
- type Dialer
- type KeyAuth
- type PasswordAuth
- type SSHProxyDialer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AuthMethod ¶
type AuthMethod interface {
GetMethod() (ssh.AuthMethod, error)
}
AuthMethod 定义获取 SSH 认证方法的接口
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) RunScriptWithSudo ¶
RunScriptWithSudo 提权执行脚本
func (*Client) RunWithSudo ¶
func (*Client) RunWithoutLogin ¶
RunWithoutLogin 执行命令并在非登录 Shell 中运行,避免加载 profile 脚本产生干扰输出
type Connector ¶
type Connector struct {
Config config.ConfigProvider
// contains filtered or unexported fields
}
Connector 负责创建 SSH 连接
func NewConnector ¶
func NewConnector(cfg config.ConfigProvider) *Connector
NewConnector 创建一个新的 Connector
type Dialer ¶
type Dialer interface {
Dial(network, addr string) (net.Conn, error)
DialContext(ctx context.Context, network, addr string) (net.Conn, error)
}
Dialer 定义网络连接行为的接口 用于统一 "直连" 和 "通过 SSH 跳板机连接" 的行为
type PasswordAuth ¶
type PasswordAuth struct {
Password string
}
PasswordAuth 实现密码认证
func (*PasswordAuth) GetMethod ¶
func (p *PasswordAuth) GetMethod() (ssh.AuthMethod, error)
type SSHProxyDialer ¶
SSHProxyDialer 实现了 Dialer 接口,通过 SSH 隧道转发流量
func (*SSHProxyDialer) DialContext ¶
Click to show internal directories.
Click to hide internal directories.