Documentation
¶
Index ¶
- func HostKeyAlgorithmsFor(knownHostsPath, host string) []string
- func HostKeyCallback(insecure bool, knownHostsPath string) (ssh.HostKeyCallback, error)
- type AuthSpec
- type ConnectSpec
- type Duration
- type DynamicSpec
- type ExecOptions
- type ExecResult
- type FileEntry
- type Forward
- type ForwardInfo
- type ForwardKind
- type JumpHost
- type LocalSpec
- type Manager
- func (m *Manager) CloneSession(srcID, newID string) (*Session, error)
- func (m *Manager) CloseAll()
- func (m *Manager) CloseForward(sessionID, forwardID string) error
- func (m *Manager) Connect(id string, spec ConnectSpec) (*Session, error)
- func (m *Manager) Disconnect(id string) error
- func (m *Manager) Get(id string) (*Session, error)
- func (m *Manager) List() []SessionInfo
- func (m *Manager) ListForwards(sessionID string) ([]ForwardInfo, error)
- func (m *Manager) OpenDynamicForward(sessionID, forwardID string, spec DynamicSpec) (*Forward, error)
- func (m *Manager) OpenLocalForward(sessionID, forwardID string, spec LocalSpec) (*Forward, error)
- func (m *Manager) OpenRemoteForward(sessionID, forwardID string, spec RemoteSpec) (*Forward, error)
- func (m *Manager) Reconnect(id string) (*Session, error)
- func (m *Manager) Sessions() map[string]*Session
- type RemoteSpec
- type Session
- func (sess *Session) CloseShell(shellID string) error
- func (s *Session) Download(remotePath, localPath string) (int64, error)
- func (s *Session) Exec(ctx context.Context, command string, opts ExecOptions) (*ExecResult, error)
- func (s *Session) FileChmod(path string, mode os.FileMode) error
- func (s *Session) FileDelete(path string) error
- func (s *Session) FileList(path string) ([]FileEntry, error)
- func (s *Session) FileMkdir(path string, recursive bool) error
- func (s *Session) FileRead(path string, offset int64, length int64) ([]byte, error)
- func (s *Session) FileRename(from, to string) error
- func (s *Session) FileStat(path string) (*FileEntry, error)
- func (s *Session) FileWrite(path string, data []byte, append bool) error
- func (sess *Session) GetShell(shellID string) (*Shell, error)
- func (s *Session) Info() SessionInfo
- func (sess *Session) ListShells() []ShellInfo
- func (sess *Session) OpenShell(shellID string, opts ShellOptions) (*Shell, error)
- func (s *Session) Upload(localPath, remotePath string) (int64, error)
- type SessionInfo
- type SessionRow
- type SessionState
- type Shell
- type ShellInfo
- type ShellOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HostKeyAlgorithmsFor ¶ added in v0.1.2
HostKeyAlgorithmsFor returns the host-key algorithm names that the user's known_hosts file has entries for, so we can advertise only those. Without this, the server may present (say) an RSA key for a host we only have an ed25519 entry for, and the knownhosts callback errors with "key mismatch" even though the same hostname has the same key the user is happy with from their CLI. Returns nil if the file is missing or has no matching entries (caller should leave HostKeyAlgorithms unset → Go's defaults).
func HostKeyCallback ¶
func HostKeyCallback(insecure bool, knownHostsPath string) (ssh.HostKeyCallback, error)
Types ¶
type AuthSpec ¶
type AuthSpec struct {
KeyPath string `json:"key_path,omitempty"`
KeyPassphrase string `json:"key_passphrase,omitempty"`
UseAgent bool `json:"use_agent,omitempty"`
// AgentSocket overrides the default $SSH_AUTH_SOCK lookup. Useful when
// the daemon was started without the env var (e.g. spawned by an MCP
// host that doesn't propagate user env), or when you want to point at
// a specific agent like 1Password's (~/Library/.../1password/t/agent.sock)
// or `gpg-agent --enable-ssh-support`.
AgentSocket string `json:"agent_socket,omitempty"`
Password string `json:"password,omitempty"`
}
func (AuthSpec) Build ¶
func (a AuthSpec) Build() ([]ssh.AuthMethod, closerList, error)
Build returns the auth methods plus a Closer that releases anything Methods opened (currently just the ssh-agent socket). Always defer cl.Close() in the caller, even on error — Build closes its own state on error paths but the caller must close on the happy path too.
type ConnectSpec ¶
type ConnectSpec struct {
User string `json:"user"`
Addresses []string `json:"addresses"`
JumpHosts []JumpHost `json:"jump_hosts,omitempty"`
Auth AuthSpec `json:"auth"`
KnownHostsPath string `json:"known_hosts_path,omitempty"`
Insecure bool `json:"insecure,omitempty"`
Timeout Duration `json:"timeout,omitempty"`
Keepalive Duration `json:"keepalive,omitempty"`
AutoReconnect bool `json:"auto_reconnect,omitempty"`
Persistent bool `json:"persistent,omitempty"`
ForwardAgent bool `json:"forward_agent,omitempty"`
// DisableSSHConfig skips the ~/.ssh/config resolution pass. By default
// the daemon mirrors the `ssh` CLI: any field the caller doesn't set is
// filled in from the user's OpenSSH config (Hostname, Port, User,
// IdentityFile, IdentityAgent, ProxyJump). Set this to true for fully
// explicit specs (e.g. CI, tests) so local user config can't influence
// the connection.
DisableSSHConfig bool `json:"disable_ssh_config,omitempty"`
}
type DynamicSpec ¶
type ExecOptions ¶
type ExecResult ¶
type Forward ¶
type Forward struct {
ID string
SessionID string
Kind ForwardKind
LocalSpec *LocalSpec
RemoteSpec *RemoteSpec
DynamicSpec *DynamicSpec
// contains filtered or unexported fields
}
func (*Forward) Info ¶
func (f *Forward) Info() ForwardInfo
type ForwardInfo ¶
type ForwardInfo struct {
ID string `json:"id"`
SessionID string `json:"session_id"`
Kind string `json:"kind"`
BindAddr string `json:"bind_addr"`
BindPort int `json:"bind_port"` // effective port (may differ from user's BindPort=0)
RemoteAddr string `json:"remote_addr,omitempty"`
RemotePort int `json:"remote_port,omitempty"`
Connections int64 `json:"connections"`
// User-supplied spec, preserved verbatim so persistence can replay
// "any free port" (BindPort=0) instead of pinning the ephemeral port.
LocalSpec *LocalSpec `json:"local_spec,omitempty"`
RemoteSpec *RemoteSpec `json:"remote_spec,omitempty"`
DynamicSpec *DynamicSpec `json:"dynamic_spec,omitempty"`
}
type ForwardKind ¶
type ForwardKind string
const ( ForwardLocal ForwardKind = "local" ForwardRemote ForwardKind = "remote" ForwardDynamic ForwardKind = "dynamic" )
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func NewManager ¶
func NewManager() *Manager
func (*Manager) CloneSession ¶
func (*Manager) CloseForward ¶
func (*Manager) Disconnect ¶
func (*Manager) List ¶
func (m *Manager) List() []SessionInfo
func (*Manager) ListForwards ¶
func (m *Manager) ListForwards(sessionID string) ([]ForwardInfo, error)
func (*Manager) OpenDynamicForward ¶
func (m *Manager) OpenDynamicForward(sessionID, forwardID string, spec DynamicSpec) (*Forward, error)
func (*Manager) OpenLocalForward ¶
func (*Manager) OpenRemoteForward ¶
func (m *Manager) OpenRemoteForward(sessionID, forwardID string, spec RemoteSpec) (*Forward, error)
type RemoteSpec ¶
type Session ¶
type Session struct {
ID string
Spec ConnectSpec
// contains filtered or unexported fields
}
func (*Session) CloseShell ¶
func (*Session) Download ¶
Download streams a remote file OR directory from the remote host over SFTP to the local filesystem. For a directory, the tree is mirrored under localPath with intermediate dirs created as needed. Symlinks are skipped.
func (*Session) Exec ¶
func (s *Session) Exec(ctx context.Context, command string, opts ExecOptions) (*ExecResult, error)
func (*Session) FileDelete ¶
func (*Session) FileRename ¶
func (*Session) Info ¶
func (s *Session) Info() SessionInfo
func (*Session) ListShells ¶
func (*Session) OpenShell ¶
func (sess *Session) OpenShell(shellID string, opts ShellOptions) (*Shell, error)
func (*Session) Upload ¶
Upload streams a local file OR directory to the remote host over SFTP. For a directory, the tree is mirrored under remotePath with intermediate dirs created as needed; permission bits are preserved on a best-effort basis. Symlinks are skipped (not followed, not recreated) to avoid escaping the source tree via a hostile or accidental local link.
type SessionInfo ¶
type SessionInfo struct {
ID string `json:"id"`
User string `json:"user"`
Addresses []string `json:"addresses"`
ActiveAddress string `json:"active_address,omitempty"`
State string `json:"state"`
LastError string `json:"last_error,omitempty"`
ConnectedAt time.Time `json:"connected_at,omitempty"`
Forwards []string `json:"forwards"`
Shells []string `json:"shells"`
Persistent bool `json:"persistent"`
AutoReconnect bool `json:"auto_reconnect"`
}
func (SessionInfo) Row ¶ added in v0.1.5
func (i SessionInfo) Row() SessionRow
type SessionRow ¶ added in v0.1.5
type SessionRow struct {
ID string `json:"id"`
User string `json:"user"`
Address string `json:"address"` // active_address, else addresses[0]
State string `json:"state"`
LastError string `json:"last_error"` // empty when none; kept (no omitempty) so tabular form stays uniform
Persistent bool `json:"persistent"`
AutoReconnect bool `json:"auto_reconnect"`
Forwards int `json:"forwards"`
Shells int `json:"shells"`
}
SessionRow is the compact, primitive-only projection used by ssh_list and status — every field is a scalar so TOON can emit the array in its compact tabular form (`[N]{fields}: row,row,row`) instead of the expanded per-element form. Detailed nested info (addresses list, attached forwards, shells) is available via ssh_info.
type SessionState ¶
type SessionState string
const ( StateConnecting SessionState = "connecting" StateConnected SessionState = "connected" StateReconnecting SessionState = "reconnecting" StateDisconnected SessionState = "disconnected" )
type Shell ¶
type Shell struct {
ID string
SessionID string
OpenedAt time.Time
// contains filtered or unexported fields
}