How to use the tunnel-ssh function in tunnel-ssh

To help you get started, we’ve selected a few tunnel-ssh examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sqlectron / sqlectron-term / src / services / db.js View on Github external
localPort,
      username: serverDefinition.ssh.user,
      port: serverDefinition.ssh.port,
      host: serverDefinition.ssh.host,
      dstPort: serverDefinition.port,
      dstHost: serverDefinition.host,
    };
    if (serverDefinition.ssh.password) {
      config.password = serverDefinition.ssh.password;
    }
    if (serverDefinition.ssh.privateKey) {
      // TODO load content in async mode
      config.privateKey = fs.readFileSync(serverDefinition.ssh.privateKey);
    }

    currentTunnel.server = tunnelssh(config);

    currentTunnel.server.on('listening', () => {
      eventHandler.onTunnelConnected(currentTunnel.server);
      resolve(currentTunnel.server);
    });

    currentTunnel.server.on('error', error => {
      currentTunnel = {};
      reject(error);
    });

    currentTunnel.server.on('close', () => {
      currentTunnel = {};
    });
  });
}
github qishibo / AnotherRedisDesktopManager / src / redisClient.js View on Github external
const sshPromise = new bluebird((resolve, reject) => {
      tunnelssh(config, function (error, server) {
        const listenAddress = server.address();
        console.log('ssh tunnel listening in', listenAddress);

        server.on('error', (error) => {
          alert('SSH Connection Error: ' + error.message);
          reject(error);
        });

        const client = redis.createClient(listenAddress.port, listenAddress.address, options);

        if (error) {
          reject(error);
        }
        else {
          resolve(client);
        }
github Viveckh / Veniqa / database / dbRequests.js View on Github external
let getDB = async () => {
    
    try {
        server = await tunnel(config.config);

        let client = null;
        try {
            console.log("URL", config.url)
            client = await MongoClient.connect(config.url, {useNewUrlParser: true});
        }
        catch(err){
            console.log("ERROR IN DB: ", err);
        }

        console.log("Connected to DB successfully!");
        database = client.db(config.databaseName);

        users_collection = database.collection(DBCollections.USERS_COLLECTION)
    }
    catch(err){
github cpsubrian / redis-explorer / src / utils / db.js View on Github external
connectToRemoteHost (host, cb) {
    let config = {
      host: host.Hostname,
      dstPort: DST_PORT,
      localPort: LOCAL_PORT,
      username: host.User,
      agent: process.env.SSH_AUTH_SOCK
    }
    this.tunnel = tunnel(config, (err) => {
      if (err) return cb(err)
      this.client = redis.createClient(config.localPort)
      this.client.on('ready', () => {
        cb()
      })
    })
  }

tunnel-ssh

Easy extendable SSH tunnel

MIT
Latest version published 4 months ago

Package Health Score

77 / 100
Full package analysis

Popular tunnel-ssh functions