Documentation
¶
Overview ¶
Package sshpool helps manage a pool of SSH clients.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config interface { // Load implements reading configuration from the given ssh_config file Load(sshConfigPath string) error // GetProxy returns proxy configuration used to establish SSH tunnel. GetProxy(host string) *proxyConfig // GetSSHConfig returns ssh ClientConfig. GetSSHConfig(host string) *ssh.ClientConfig }
Config is the interface that wraps the SSH and TLS configurations
func FromClientConfig ¶
func FromClientConfig(clientConfig *ssh.ClientConfig) (Config, error)
FromClientConfig creates a new instance of Config structure and populates it with the given ClientConfig values.
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
Pool is a pool of SSH clients to reuse.
Clients are pooled by the hostname they are connected to.
Users should call Get, which returns a Client from the pool if available, or creates and returns a new Client. The returned Client is not guaranteed to be good, e.g., the connection may have broken while the Client was in the pool.
The user should put the SSH client back into the pool after use. The user should not close the Client as Pool will close it if bad.
The user should Close the pool after use, to free any SSH Clients in the pool.
func New ¶
New returns a new Pool. The provided ssh config is used for new SSH connections if pool has none to reuse.
config: SSH configuration to configure the new clients. tlsConfig: Optional TLS configuration to establish SSH connections over TLS channel.
func (*Pool) GetContext ¶
GetContext returns a good SSH client within the context timeout.