Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Tunnel ¶
type Tunnel struct {
// contains filtered or unexported fields
}
Tunnel manages an SSH tunnel that forwards local connections to a remote host through an SSH server. It opens a local TCP listener on a random port and forwards each accepted connection to the specified remote host:port via the SSH connection.
func NewTunnel ¶
func NewTunnel(sshHost string, sshPort int, sshUser, sshKeyFile, sshPassword string, remoteHost string, remotePort int) (*Tunnel, error)
NewTunnel creates a new SSH tunnel configuration. It connects to the SSH server at sshHost:sshPort using the provided credentials. Authentication methods are tried in order: key file (if provided), SSH agent (if SSH_AUTH_SOCK is set), then password (if provided).
The tunnel will forward local connections to remoteHost:remotePort through the SSH server. Call Start() to begin accepting connections.
func (*Tunnel) LocalPort ¶
LocalPort returns the local port the tunnel listener is bound to. Returns 0 if the tunnel has not been started.