MCPcopy Index your code
hub / github.com/elliotchance/sshtunnel

github.com/elliotchance/sshtunnel @v1.6.2

Chat with this repo
repository ↗ · DeepWiki ↗ · release v1.6.2 ↗ · + Follow
17 symbols 39 edges 5 files 2 documented · 12% 3 cross-repo links
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

🚇 sshtunnel

Ultra simple SSH tunnelling for Go programs.

Installation

go get -u github.com/elliotchance/sshtunnel

Or better with dep:

dep ensure -add github.com/elliotchance/sshtunnel

Example

// Setup the tunnel, but do not yet start it yet.
tunnel := sshtunnel.NewSSHTunnel(
   // User and host of tunnel server, it will default to port 22
   // if not specified.
   "ec2-user@jumpbox.us-east-1.mydomain.com",

   // Pick ONE of the following authentication methods:
   sshtunnel.PrivateKeyFile("path/to/private/key.pem"), // 1. private key
   ssh.Password("password"),                            // 2. password
   sshtunnel.SSHAgent(),                                // 3. ssh-agent

   // The destination host and port of the actual server.
   "dqrsdfdssdfx.us-east-1.redshift.amazonaws.com:5439",

   // The local port you want to bind the remote port to.
   // Specifying "0" will lead to a random port.
   "8443",
)

// You can provide a logger for debugging, or remove this line to
// make it silent.
tunnel.Log = log.New(os.Stdout, "", log.Ldate | log.Lmicroseconds)

// Start the server in the background. You will need to wait a
// small amount of time for it to bind to the localhost port
// before you can start sending connections.
go tunnel.Start()
time.Sleep(100 * time.Millisecond)

// NewSSHTunnel will bind to a random port so that you can have
// multiple SSH tunnels available. The port is available through:
//   tunnel.Local.Port

// You can use any normal Go code to connect to the destination server
// through localhost. You may need to use 127.0.0.1 for some libraries.
//
// Here is an example of connecting to a PostgreSQL server:
conn := fmt.Sprintf("host=127.0.0.1 port=%d username=foo", tunnel.Local.Port)
db, err := sql.Open("postgres", conn)

// ...

Extension points exported contracts — how you extend this code

Core symbols most depended-on inside this repo

logf
called by 19
ssh_tunnel.go
Close
called by 6
ssh_tunnel.go
String
called by 6
endpoint.go
NewEndpoint
called by 4
endpoint.go
Printf
called by 1
ssh_tunnel.go
newConnectionWaiter
called by 1
ssh_tunnel.go
Listen
called by 1
ssh_tunnel.go
Serve
called by 1
ssh_tunnel.go

Shape

Method 8
Function 6
Struct 2
Interface 1

Languages

Go100%

Modules by API surface

ssh_tunnel.go11 symbols
endpoint.go3 symbols
ssh_agent.go1 symbols
private_key_file.go1 symbols
endpoint_test.go1 symbols

For agents

$ claude mcp add sshtunnel \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact