One to connect them all !
Tunnel-ssh is based on the fantastic ssh2 library by Brian White. Trouble ? Please study the ssh2 configuration.
Latest Relese 4.1.3
- Closing sshconnections correctly thx @actionshrimp
- Improved readme
- Updated modules
Special thanks to @vweevers and @dickeyxxx
- If you don't want to wrap a tunnel around your code: inject-tunnel-ssh
- If you need it the other way around: reverse-tunnel-ssh
By default tunnel-ssh will close the tunnel after a client disconnects, so your cli tools should work in the same way, they do if you connect directly. If you need the tunnel to stay open, use the "keepAlive:true" option within the configuration.
var config =...keepAlive:true;var tnl =;// you can also close the tunnel from here...;
Understanding the configuration
A local server listening for connections to forward via ssh Description: This is where you bind your interface. Properties: ** localHost (default is '127.0.0.1') ** localPort (default is dstPort)
The ssh configuration Description: The host you want to use as ssh-tunnel server. Properties: ** host ** port (22) ** username ** ...
The destination host configuration (based on the ssh host) Imagine you just connected to The host you want to connect to. (via host:port) now that server connects requires a target to tunnel to. Properties: ** dstHost (localhost) ** dstPort
var config =username:'root'Password:'secret'host:sshServerport:22dstHost:destinationServerdstPort:27017localHost:'127.0.0.1'localPort: 27000;var tunnel = ;;
tunnel-ssh assumes that you want to map the same port on a remote machine to your localhost using the ssh-server on the remote machine.
var config =username:'root'dstHost:'remotehost.with.sshserver.com'dstPort:27017privateKey:passphrase:'secret';
More configuration options
tunnel-ssh pipes the configuration direct into the ssh2 library so every config option provided by ssh2 still works. ssh2 configuration
var tunnel = ;//map port from remote 3306 to localhost 3306var server =;// Use a listener to handle errors outside the callbackserver;