Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

strong-tunnel

Package Overview
Dependencies
Maintainers
9
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

strong-tunnel

Semi-transparent wrapper for arbitrary network connections over ssh2

  • 1.1.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
117
decreased by-22%
Maintainers
9
Weekly downloads
 
Created
Source

strong-tunnel

Easy tunnelling over ssh2.

Usage

There is nothing to configure, but some environment variables are used to set defaults if no options are given.

var st = require('strong-tunnel');

st(someUrl, sshOpts, function(err, url) {
  // if someUrl was plain http, url will be someUrl
  // if someUrl was http+ssh://, url points to a local ephemeral tunnel
  // sshOpts is optional with defaults described below.
  http.get(url, onResponse);
});

Username

Your current local username is assumed to be the username used for ssh. To override this you can set the LOGNAME environment variable to the desired username before the tunnel URL is created.

Credentials

To keep the API simple, it is assumed that an ssh agent is already running, that the path to its domain socket is in the SSH_AUTH_SOCK environment variable, and that an appropriate private key has been loaded into that agent.

This is usually done for you in modern *nix environments as part of your login shell/session. See ssh-agent(1) for more information about ssh agents.

Longer Example

var fmt = require('util').format;
var http = require('http');
var st = require('strong-tunnel');

var server = http.createServer(function(req, res) {
  res.end(JSON.stringify(req.headers));
});

var sshOpts = {
  host: '127.0.0.1',
};

server.listen(3030, function() {
  var direct = 'http://127.0.0.1:3030/';
  var tunneled = 'http+ssh://127.0.0.1:3030/';

  // Standard request using URL string
  http.get(direct, resLog('%s using %s:', direct, direct));

  // URL is only modified if a tunnelling URL was given
  st(direct, function(err, url) {
    if (err) throw err;
    // url == direct, unmodified
    http.get(url, resLog('%s using %s:', direct, url));
  });

  // optional second argument containing ssh config
  st(tunneled, sshOpts, function(err, url) {
    if (err) throw err;
    // url != tunneled, is modified
    http.get(url, resLog('%s using %s:', tunneled, url));
  });

  server.unref();
});

function resLog(prefix) {
  prefix = fmt.apply(null, arguments);
  return function onResponse(res) {
    res.on('data', function(d) {
      console.log('%s -> %s', prefix, d);
    });
  };
}

Keywords

FAQs

Package last updated on 06 May 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc