Documentation
¶
Index ¶
- Constants
- Variables
- func NewSSHTools(options ...SSHOption) (taskengine.ToolsRepo, error)
- type HostKeyVerifier
- type SSHConfig
- type SSHOption
- func WithAllowedHosts(entries ...string) SSHOption
- func WithClientCache() SSHOption
- func WithCustomHostKeyCallback(callback ssh.HostKeyCallback) SSHOption
- func WithDefaultPort(port int) SSHOption
- func WithDefaultTimeout(timeout time.Duration) SSHOption
- func WithFileRoot(dir string) SSHOption
- func WithKnownHostsFile(path string) SSHOption
- func WithName(name string) SSHOption
- func WithStrictHostKey() SSHOption
- type SSHResult
- type SSHTools
- func (h *SSHTools) Close() error
- func (h *SSHTools) Exec(ctx context.Context, _ time.Time, input any, _ bool, ...) (any, taskengine.DataType, error)
- func (h *SSHTools) GetSchemasForSupportedTools(_ context.Context) (map[string]*openapi3.T, error)
- func (h *SSHTools) GetToolsForToolsByName(_ context.Context, name string) ([]taskengine.Tool, error)
- func (h *SSHTools) Precheck(ctx context.Context, input any, tools *taskengine.ToolsCall) error
- func (h *SSHTools) Supports(context.Context) ([]string, error)
Constants ¶
const ToolExecuteRemoteCommand = "execute_remote_command"
ToolExecuteRemoteCommand is the one tool; it is unprefixed because the namespace scopes toolsets, not tools, and this is the seeded HITL policy key.
const ToolsProviderName = "native-ssh"
ToolsProviderName is the registered toolset name an allowlist addresses; the native- scope is a namespace, so a declared MCP source cannot mint the same key.
Variables ¶
var ( // ErrNoAllowedHosts means nothing enumerated a reachable host, so the // toolset can reach none; declaring it is not by itself consent to a machine. ErrNoAllowedHosts = errors.New("ssh: no host allowlist") // ErrHostNotAllowed means the requested host is outside the enumerated allowlist. ErrHostNotAllowed = errors.New("ssh: host not in the allowlist") // ErrHostKeyMismatch means the server presented a key other than the pinned one. ErrHostKeyMismatch = errors.New("ssh: host key mismatch") )
Functions ¶
func NewSSHTools ¶
func NewSSHTools(options ...SSHOption) (taskengine.ToolsRepo, error)
NewSSHTools fails rather than returning a toolset whose host key verification could not be established.
Types ¶
type HostKeyVerifier ¶
type HostKeyVerifier struct {
// contains filtered or unexported fields
}
HostKeyVerifier checks a presented key against known_hosts plus any pinned fingerprints. An unknown host is always refused: there is no safe default accept for an unverified host key, so non-strict only decides whether an unreadable known_hosts file fails construction.
func NewHostKeyVerifier ¶
func NewHostKeyVerifier(knownHostsFile string, strict bool) (*HostKeyVerifier, error)
func (*HostKeyVerifier) AddKnownHost ¶
func (v *HostKeyVerifier) AddKnownHost(host, fingerprint string)
AddKnownHost pins host to an exact SHA256 fingerprint, which is accepted in place of a known_hosts entry for that host alone.
func (*HostKeyVerifier) VerifyHostKey ¶
type SSHOption ¶
SSHOption configures the toolset; an option that cannot be satisfied fails construction rather than degrading a security boundary silently.
func WithAllowedHosts ¶
WithAllowedHosts is the operator's ceiling on reach: every call must match one of these entries, and a declaration's own allowlist can only narrow within it.
func WithClientCache ¶
func WithClientCache() SSHOption
func WithCustomHostKeyCallback ¶
func WithCustomHostKeyCallback(callback ssh.HostKeyCallback) SSHOption
func WithDefaultPort ¶
func WithDefaultTimeout ¶
func WithFileRoot ¶
WithFileRoot scopes every local file this toolset reads — the known_hosts file and any private key file — to dir: a read that resolves outside it is refused. It is the operator's ceiling on local file reach, the same containment seam local_fs uses. Unset, only the control-plane deny binds (see containFile).
func WithKnownHostsFile ¶
func WithStrictHostKey ¶
func WithStrictHostKey() SSHOption
WithStrictHostKey records the intent; the verifier is built once after every option has run, so this no longer depends on being ordered after WithKnownHostsFile.
type SSHResult ¶
type SSHResult struct {
ExitCode int `json:"exit_code"`
Stdout string `json:"stdout"`
Stderr string `json:"stderr"`
Duration float64 `json:"duration_seconds"`
Command string `json:"command"`
Host string `json:"host"`
User string `json:"user"`
Success bool `json:"success"`
Truncated bool `json:"truncated,omitempty"`
Error string `json:"error,omitempty"`
HostKey string `json:"host_key,omitempty"`
}
type SSHTools ¶
type SSHTools struct {
// contains filtered or unexported fields
}