JSPM

  • Created
  • Published
  • Downloads 176485
  • Score
    100M100P100Q168136F
  • License ISC

Easy ssh tunneling

Package Exports

  • tunnel-ssh

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (tunnel-ssh) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Tunnel-SSH

Simple SSH tunneling in node.js

Install

npm install tunnel-ssh

Example (connect to remote mongo)

var config = {
    remotePort: 27017, //localport
    localPort: 27017, //remoteport
    verbose: true, // dump information to stdout
    disabled: false, //set this to true to disable tunnel (useful to keep architecture for local connections)
    sshConfig: { //ssh2 configuration (https://github.com/mscdex/ssh2)
        host: '<yourRemoteIp>',
        port: 22,
        username: 'root',
        privateKey: require('fs').readFileSync('<pathToKeyFile>'),
        passphrase: 'verySecretString' // option see ssh2 config
    }
};

var tunnel = new Tunnel(config);
tunnel.connect(function (error) {
    console.log(error);
    //or start your remote connection here .... 
    //mongoose.connect(...);


    //close tunnel to exit script 
    tunnel.close();
});

Example (create a tunnel for mysql)

    var config = {
        remoteHost: '<mysql server host>', // mysql server host
        remotePort: 3306, // mysql server port
        localPort: 33333, // a available local port
        verbose: true, // dump information to stdout
        disabled: false, //set this to true to disable tunnel (useful to keep architecture for local connections)
        sshConfig: { //ssh2 configuration (https://github.com/mscdex/ssh2)
            host: '<ssh server host>',
            port: 22,
            username: 'root',
            privateKey: require('fs').readFileSync('<pathToKeyFile>'),
            passphrase: 'verySecretString' // option see ssh2 config
        }
    };

    var tunnel = new Tunnel(config);
    tunnel.connect(function (error) {
        console.log(error);
        //or start your remote connection here .... 
        //mongoose.connect(...);


        //close tunnel to exit script 
        tunnel.close();
    });

mysql config

mysql_config = {
    host: '127.0.0.1',
    port: '33333',
    user: 'xxx',
    password: 'xxx'
}