Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

ssh tunnel connect to mongodb in node.js

var config = {
    username:'myusername',
    host:'my.ip.address',
    agent : process.env.SSH_AUTH_SOCK,
    privateKey:require('fs').readFileSync('/Users/myusername/.ssh/id_rsa'),
    port:22,
    dstPort:27017,
    password:'mypassword'
};

var server = tunnel(config, function (error, server) {
    if(error){
        console.log("SSH connection error: " + error);
    }
    mongoose.connect('mongodb://localhost:27017/mydbname');

    var db = mongoose.connection;
    db.on('error', console.error.bind(console, 'DB connection error:'));
    db.once('open', function() {
        // we're connected!
        console.log("DB connection successful");
    });
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: heroku node js h21 backend connection refused 
Javascript :: p5js add canvas in middle 
Javascript :: firebase angular send notification to by tocken 
Javascript :: how to update value in nested json using id in javascript 
Javascript :: quasar electron getPath 
Javascript :: rdlc refresh dataset from object 
Javascript :: recuperer une image dans la base de données avec angular 
Javascript :: getElementbyhref 
Javascript :: add padding to a div slow jquery 
Javascript :: how to add a object in world in matter.js 
Javascript :: ipa failed react native after processing 
Javascript :: how to get header in all the pages in visualforce page 
Javascript :: renderIndicator example react responsive carousel 
Javascript :: Ivy J. Livingston 
Javascript :: removeeventlistener not working in class javascript 
Javascript :: extend static class javascript 
Javascript :: Noblox Shout Command 
Javascript :: react strap documentation 
Javascript :: JSDOM - serialize() // returns dom as string 
Javascript :: pwa tabs chrome extension 
Javascript :: how to auto click webpage in angular 
Javascript :: get all youtube playlist videos as json without api python 
Javascript :: rails json exclude nested attribute 
Javascript :: position of element related to parent div in jquery 
Javascript :: bjsmasth update 
Javascript :: petrov attack 
Javascript :: wherein knex 
Javascript :: filter a query string with comparison operator 
Javascript :: get single element typeorm 
Javascript :: javascript get local timezone 
ADD CONTENT
Topic
Content
Source link
Name
9+3 =