Documentation
¶
Index ¶
Constants ¶
const DefaultPort = 22
Variables ¶
var SSHSigner ssh.Signer
SSHSigner public key
Functions ¶
func Run ¶
func Run(ctx context.Context, provider SSHProvider, addr string, cmd string) (result *tlw.RunResult)
Run executes command on the target address by SSH.
func RunBackground ¶
func RunBackground(ctx context.Context, provider SSHProvider, addr string, cmd string) (result *tlw.RunResult)
RunBackground executes command on the target address by SSH in background.
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 NewDefaultConfig ¶
NewDefaultConfig creates a new instance of Config structure and populates it with the default SSH config.
type Forwarder ¶
type Forwarder struct {
// contains filtered or unexported fields
}
Forwarder creates a listener that forwards TCP connections to another host over an already-established SSH connection.
A pictoral explanation:
Local | SSH Host | Remote -----------------------------------+----------------+-------------
(local-to-remote)
[client] <- TCP -> [Forwarder] <- SSH -> [sshd] <- TCP -> [server]
(remote-to-local)
[server] <- TCP -> [Forwarder] <- SSH -> [sshd] <- TCP -> [client]
func (*Forwarder) ListenAddr ¶
ListenAddr returns the address used to listen for connections.
type SSHClient ¶
type SSHClient interface { NewSession() (*ssh.Session, error) IsAlive() bool Close() error Client() *ssh.Client ForwardLocalToRemote(localAddr, remoteAddr string, errFunc func(error)) (*Forwarder, error) }
SSHClient provides base API to work with SSH client.
type SSHProvider ¶
type SSHProvider interface { Get(ctx context.Context, addr string) (SSHClient, error) CloseClient(ctx context.Context, c SSHClient) error Close() error Config() Config SetUser(username string) UseClientPool() bool Clone() SSHProvider }
SSHProvider provide access to SSH client manager.
Provider gives option to use pool or create new client always.
func NewProvider ¶
func NewProvider(config Config) SSHProvider
NewProvider creates new provider for use.
clientConfig: SSH configuration to configure the new clients. tlsConfig: Optional TLS configuration to establish SSH connections over TLS channel.