Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Conn ¶
type Conn interface {
NewSFTP(ctx context.Context) (SFTPClient, error)
NewSession(ctx context.Context) (Session, error)
SendKeepAlive(ctx context.Context) error
Close() error
}
Conn describes the operations required from an SSH connection.
type DialConfig ¶
type DialConfig struct {
// Host is passed to ssh_config resolution as the target. It may be a
// literal hostname or IP, or a Host alias defined in ~/.ssh/config.
Host string
// User, if non-empty, overrides the user resolved from ssh_config.
User string
// Port, if non-zero, overrides the port resolved from ssh_config.
Port int
// Timeout is the TCP connect timeout used when ssh_config's
// ConnectTimeout is unset. Zero means no timeout.
Timeout time.Duration
}
DialConfig specifies the minimum identification parameters for a machineproxy SSH connection. Everything else (identity file, known hosts, algorithm lists, keepalives, etc.) is resolved from the user's ssh_config.
type Dialer ¶
type Dialer struct {
// Dial establishes a fresh SSH connection to the remote.
Dial func(ctx context.Context) (Conn, error)
// Addr is the resolved "host:port" address of the remote after
// ssh_config Hostname/Port substitutions.
Addr string
// KeepAliveInterval is ServerAliveInterval from ssh_config, or zero
// when the user did not configure keepalives.
KeepAliveInterval time.Duration
}
Dialer carries a dial closure and metadata derived from the resolved ssh_config options. NewDialer resolves the configuration once so every reconnect attempt reuses the same ClientConfig.
func NewDialer ¶
func NewDialer(cfg DialConfig) (*Dialer, error)
NewDialer resolves ssh_config for cfg.Host and returns a Dialer ready to be handed to a Manager. Identity keys, known_hosts, crypto preferences and timeouts all come from the library's ssh_config resolution.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func NewManager ¶
func (*Manager) CurrentConn ¶
func (*Manager) IsConnected ¶
func (*Manager) LastErr ¶
LastErr returns the most recent connection error, or nil if the last attempt succeeded. Useful for surfacing why the manager is not connected.
func (*Manager) NewSession ¶
NewSession creates an SSH session from the current connection. Returns an error if the connection is not established.
func (*Manager) SFTP ¶
func (m *Manager) SFTP() SFTPClient
type SFTPClient ¶
type SFTPClient interface {
Close() error
}
SFTPClient is a minimal close-able interface used by the connection manager. Concrete code can wrap *sftp.Client.