Documentation
¶
Overview ¶
Package tunnel implements a tunnel to another machine from which we can Dial other machines or Listen to remote ports. For now this library won't check host keys (it just accepts all) and for simplicity it assumes that you are using an ssh-agent to access your ssh keys.
Typical use:
First we create the tunnel
tunnel, err := tunnel.Create(tunnel.Config{ Hops: []string{ "bob@bastion.example.com:22", "alice@inside.example.com:22", }, }) ...
Then we connect using the tunnel
conn, err := tunnel.Dial("tcp", "service.example.com:4711") ...
If everything went according to plan you now have a tunnel that terminates at inside.example.com (since it is the last hop) and connects from there to port 4711 on service.example.com
You can also listen on the remote endpoint.
listener, err := tunnel.Listen("tcp", ":80") ...
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrConnectAgent indicates that we failed to connect to the ssh-agent ErrConnectAgent = errors.New("failed to connect to ssh-agent") // ErrNoHopsSpecified indicates that the caller did not supply any hops. We need at least one hop. ErrNoHopsSpecified = errors.New("no hops specified") // ErrParsingHops indicates that at least one hop had an improper format ErrParsingHops = errors.New("error parsing hops") // ErrOpeningAuthSock indicates that we failed to open the ssh-agent socket ErrOpeningAuthSock = errors.New("error opening ssh-agent socket") // ErrCreatingConnection indicates we were unable to create a connection when building the tunnel ErrCreatingConnection = errors.New("error creating connection") // ErrClosingHop indicates that we got an error while trying to close a connection when tearing // down the tunnel. ErrClosingHop = errors.New("error closing hop") )
View Source
var (
ErrInvalidFormat = errors.New("invalid format")
)
errors
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // Hops is a list of user@host:port elements, the last of which defines // the target host. We need at least one entry, but we support an arbitrary // number of hops. Hops []string }
Config for Tunnel.
Click to show internal directories.
Click to hide internal directories.