Skip to content

yushaolong10/sshTunnel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sshTunnel

Description

ssh tunnel forwarding library for Go. Implemented using golang.org/x/crypto/ssh . Like linux command:

ssh -N -f -L 3307:remoteHost:3306 sshUsername@sshHostname

Installation

go get -u github.com/alwaysthanks/sshTunnel

Examples

1.simple ssh forwarding

sshTool, err := NewSSHTool(sshHostname, sshUsername, sshPassword, "")
if err != nil {

}
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
proxyServer, err := NewTunnelServer(ctx, localAddr, remoteAddr, sshTool)
if err != nil {

}
//run ssh proxy
go proxyServer.Start()
//begin your service

2.use ssh connections pool

sshTool, err := NewSSHTool(sshHostname, sshUsername, sshPassword, "")
if err != nil {

}
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
//here use ssh pool
proxyServer, err := NewTunnelServerWithPool(ctx, localAddr, remoteAddr, sshTool)
if err != nil {

}
//run ssh proxy
go proxyServer.Start()
//begin your service

License

View the LICENSE file

About

ssh tunnel forwarding library for Go.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages