reverse-tunnel-ssh-privatekey

1.0.2 • Public • Published

reverse-tunnel-ssh-privatekey

Easy ssh reverse tunnel

Tunnel-SSH Logo

##How to use

npm i reverse-tunnel-ssh-privatekey (--save)
// Tunnel your local port 8000 to tunneltest.com:8000

//tunnel is a ssh2 clientConnection object
var tunnel = require('reverse-tunnel-ssh-privatekey');
tunnel({
  host: 'tunneltest.com',
  username: 'root',
  //privateKey: require('fs').readFileSync('/path_to_RSA_key'),
  dstHost: '0.0.0.0', // bind to all IPv4 interfaces
  dstPort: 8000,
  //srcHost: '127.0.0.1', // default
  //srcPort: dstPort // default is the same as dstPort
}, function(error, clientConnection) {
  //
});

// Tunnel your local port 8000 to a free port on tunneltest.com

var conn = tunnel({
  host: 'tunneltest.com',
  username: 'somebody',
  //privateKey: require('fs').readFileSync('/path_to_RSA_key'),
  dstHost: '0.0.0.0', // bind to all IPv4 interfaces
  dstPort: 0, // dynamically choose an open port on tunneltest.com
  //srcHost: '127.0.0.1', // default
  srcPort: 8000, // must be specified if dstPort=0
}, function (error, clientConnection) {
  //
});
conn.on('forward-in', function (port) {
  console.log('Forwarding from tunneltest.com:' + port);
});

If you plan to expose a local port on a remote machine (external interface) you need to enable the "GatewayPorts" option in your 'sshd_config'

# What ports, IPs and protocols we listen for
Port 22
GatewayPorts yes

Package Sidebar

Install

npm i reverse-tunnel-ssh-privatekey

Weekly Downloads

0

Version

1.0.2

License

MIT

Unpacked Size

7.07 kB

Total Files

6

Last publish

Collaborators

  • martleib