sshtunnel

package
v0.0.0-...-db7fb94 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 28, 2019 License: MIT Imports: 10 Imported by: 1

Documentation

Overview

Package sshtunnel lets you dial (and re-publish locally) SSH-tunneled TCP and Unix domain socket connections using external SSH client processes.

Index

Constants

View Source
const CommandTemplateOpenSSHText = `ssh -nNT -L "{{.LocalIP}}:{{.LocalPort}}:{{.RemoteAddr}}" -p "{{.SSHPort}}"  "{{.User}}@{{.SSHHost}}" {{.ExtraArgs}}`

CommandTemplateOpenSSHText is a command template text for the openssh `ssh` client binary.

View Source
const CommandTemplatePuTTYText = `putty -ssh -NT "{{.User}}@{{.SSHHost}}" -P "{{.SSHPort}}"  -L "{{.LocalIP}}:{{.LocalPort}}:{{.RemoteAddr}}" {{.ExtraArgs}}`

CommandTemplatePuTTYText is a command template text for the PuTTY client.

Variables

View Source
var CommandTemplateOpenSSH = mustParse(CommandTemplateOpenSSHText)

CommandTemplateOpenSSH is a command template for the openssh `ssh` client binary.

View Source
var CommandTemplatePuTTY = mustParse(CommandTemplatePuTTYText)

CommandTemplatePuTTY is a command template for the PuTTY client.

Functions

func Dial

func Dial(remoteAddr string, config *Config) (net.Conn, <-chan error, error)

Dial opens a tunnelled connection to the given address using the configured external SSH client.

func DialContext

func DialContext(ctx context.Context, remoteAddr string, config *Config) (net.Conn, <-chan error, error)

DialContext opens a tunnelled connection to the given address using the configured external SSH client and the provided context.

func Listen

func Listen(laddr net.Addr, raddr string, config *Config) (net.Listener, <-chan error, error)

Listen is ListenContext with context.Background()

func ListenContext

func ListenContext(ctx context.Context, laddr net.Addr, raddr string, config *Config) (net.Listener, <-chan error, error)

ListenContext serves an SSH tunnel to a remote address on the given local network address `laddr`. The remote endpoint of the tunneled connections is given by the network and addr parameters.

Types

type Config

type Config struct {
	// SSH user
	User string
	// SSH server host
	SSHHost string
	// SSH server port
	SSHPort string
	// SSH client command template.
	// A template that may refer to fields from struct commandTemplateData.
	// Its output is split according to shell splitting rules and executed.
	CommandTemplate *template.Template
	// This value will be passed to the CommandTemplate in the ExtraArgs field.
	CommandExtraArgs string
	// Optional callback to preform any additional configuration of the SSH client command.
	CommandConfig func(*exec.Cmd) error
	// Backoff config used when connecting to the external client.
	Backoff backoff.Config
	// Local IP address to listen on (optional).
	LocalIP *net.IP
}

Config is an SSH tunnel configuration using an external SSH client command.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL