Documentation
¶
Index ¶
- func NewConnector(cfgProvider config.ConfigProvider, opts ...ssh.Option) *ssh.Connector
- func NewConnectorWithAdapterOptions(cfgProvider config.ConfigProvider, adpOpts []Option, sshOpts ...ssh.Option) *ssh.Connector
- func NewConnectorWithInteraction(cfgProvider config.ConfigProvider, interaction ssh.InteractionHandler, ...) *ssh.Connector
- func NewNonInteractiveConnector(cfgProvider config.ConfigProvider, opts ...ssh.Option) *ssh.Connector
- type CredentialResolver
- type Option
- func WithCredentialRecording(enabled bool) Option
- func WithCredentialService(service *credential.Service) Option
- func WithCredentialSource(source CredentialResolver) Option
- func WithGlobalSessionAuth(auth SessionAuth) Option
- func WithNonInteractive(nonInteractive bool) Option
- func WithRememberConfirmation(confirm func(context.Context, string) (bool, error)) Option
- func WithSessionAuthOverride(nodeID string, auth SessionAuth) Option
- type SSHAdapter
- func (a *SSHAdapter) GetConfig(nodeID string) (*ssh.ClientConfig, error)
- func (a *SSHAdapter) ResolveSecret(ctx context.Context, req ssh.SecretRequest) ([]byte, error)
- func (a *SSHAdapter) UpdateAuth(ctx context.Context, ...) (string, error)
- func (a *SSHAdapter) UpdateSudo(ctx context.Context, nodeID, sudoUpdateToken string, mode ssh.SudoMode, ...) (string, error)
- type SessionAuth
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewConnector ¶
NewConnector 是一个辅助方法,快速创建组装好 Adapter 的 ssh.Connector,支持传入 Option 进行显式注入配置。
func NewConnectorWithAdapterOptions ¶ added in v0.12.0
func NewConnectorWithAdapterOptions(cfgProvider config.ConfigProvider, adpOpts []Option, sshOpts ...ssh.Option) *ssh.Connector
NewConnectorWithAdapterOptions 创建组装好 Adapter 选项和 SSH 选项的 Connector
func NewConnectorWithInteraction ¶ added in v0.12.0
func NewConnectorWithInteraction(cfgProvider config.ConfigProvider, interaction ssh.InteractionHandler, opts ...ssh.Option) *ssh.Connector
NewConnectorWithInteraction creates a connector with a presentation-layer interaction handler supplied by the composition root.
func NewNonInteractiveConnector ¶ added in v0.10.0
func NewNonInteractiveConnector(cfgProvider config.ConfigProvider, opts ...ssh.Option) *ssh.Connector
NewNonInteractiveConnector 创建一个非交互式的 Connector,避免在批量操作中阻塞等待输入,支持传入 Option。
Types ¶
type CredentialResolver ¶ added in v0.12.0
type CredentialResolver interface {
Resolve(ctx context.Context, ref credential.Ref) (credential.Secret, error)
}
CredentialResolver 描述能够根据 Ref 解析 Secret 的契约(如 *credential.Registry)
type Option ¶ added in v0.12.0
type Option func(*SSHAdapter)
Option 定义 SSHAdapter 的配置选项
func WithCredentialRecording ¶ added in v0.12.0
WithCredentialRecording controls persistence of secrets discovered during a connection. Composition roots apply remember policy and terminal ownership; explicit credential form actions use the service independently.
func WithCredentialService ¶ added in v0.12.0
func WithCredentialService(service *credential.Service) Option
WithCredentialService injects the transactional writer used when an interactive connection is explicitly allowed to remember a discovered secret. Secrets must never be written through the legacy configuration fields.
func WithCredentialSource ¶ added in v0.12.0
func WithCredentialSource(source CredentialResolver) Option
WithCredentialSource 注入凭据解析器(如 credential.Registry),用于解析 Ref 引用
func WithGlobalSessionAuth ¶ added in v0.12.0
func WithGlobalSessionAuth(auth SessionAuth) Option
WithGlobalSessionAuth 注入会话级全局默认机密覆盖(当特定节点未显式指定 override 时生效)
func WithNonInteractive ¶ added in v0.12.0
WithNonInteractive 标记该适配器为非交互式环境(如批处理、MCP、Playbook)
func WithRememberConfirmation ¶ added in v0.12.0
WithRememberConfirmation injects a presentation-owned decision made only after authentication succeeds and before a newly discovered secret is saved.
func WithSessionAuthOverride ¶ added in v0.12.0
func WithSessionAuthOverride(nodeID string, auth SessionAuth) Option
WithSessionAuthOverride 注入特定节点的会话级临时机密覆盖
type SSHAdapter ¶
type SSHAdapter struct {
// contains filtered or unexported fields
}
SSHAdapter 实现 ssh.ConnectionProvider, ssh.SecretResolver, ssh.CredentialRecorder 接口,作为业务模型与底层 SSH 的防腐层
func NewNonInteractiveSSHAdapter ¶ added in v0.10.0
func NewNonInteractiveSSHAdapter(cfgProvider config.ConfigProvider, opts ...Option) *SSHAdapter
NewNonInteractiveSSHAdapter 创建非交互式的 SSH 适配器
func NewSSHAdapter ¶
func NewSSHAdapter(cfgProvider config.ConfigProvider, opts ...Option) *SSHAdapter
NewSSHAdapter 创建 SSH 适配器
func (*SSHAdapter) GetConfig ¶
func (a *SSHAdapter) GetConfig(nodeID string) (*ssh.ClientConfig, error)
GetConfig 获取底层 SSH 客户端需要的配置
func (*SSHAdapter) ResolveSecret ¶ added in v0.12.0
func (a *SSHAdapter) ResolveSecret(ctx context.Context, req ssh.SecretRequest) ([]byte, error)
ResolveSecret 从当前配置模型解析认证或提权所需机密,并严格校验与连接快照的一致性
func (*SSHAdapter) UpdateAuth ¶
func (a *SSHAdapter) UpdateAuth(ctx context.Context, nodeID, authUpdateToken, password, keyPath, passphrase string) (string, error)
UpdateAuth 处理密码或私钥密码的回写并返回本次提交后的新认证令牌