Skip to content
Easy ssh2 tunneling
JavaScript
Find file
New pull request
Latest commit a53509d @parro-it 0.1.0
Failed to load latest commit information.
.editorconfig first commit
.gitignore first commit
.travis.yml travis
index.js test exit
license first commit
package.json 0.1.0
readme.md readme + travis:gp
test.js travis

readme.md

open-ssh-tunnel

Easy ssh tunneling function based on ssh2 library

Inspired by tunnel-ssh, but with simplified, more modern code.

Travis Build Status NPM module NPM downloads

Installation

npm install --save open-ssh-tunnel

Usage

  const openSshTunnel = require('open-ssh-tunnel');
  async function openATunnel() {
    const server = await openSshTunnel({
      host: 'your.server.address.com',
      username: 'you',
      password: 'secret',
      srcPort: 3306,
      srcAddr: '127.0.0.1',
      dstPort: 3306,
      dstAddr: '127.0.0.1',
      readyTimeout: 1000,
      forwardTimeout: 1000
    });

    // you can now connect to your
    // forwarded tcp port!

    // later, when you wnat to lcose the tunnel
    server.close();
  }

API

The module exports openSshTunnel function. It return a promise that resolve to a node net server instance if tunnel is opened, otherwise is rejected with an error.

Options

  • srcIP and srcPort as the originating address and port and dstIP and dstPort as the remote destination address and port. This are options passed to ssh2 Client.forwardOut method.

  • forwardTimeout - How many millisecond to wait before reject with a timeout error.

  • All other options are passed to ssh2 Client.connect method.

License

The MIT License (MIT)

Copyright (c) 2015 parro-it

Something went wrong with that request. Please try again.