Tag: ssh

Node.js使用tunnel-sshbuild立与远程mysql服务器的连接

我正在使用tunnel-ssh模块使用node.jsbuild立到远程mysql数据库的连接。 文档很差,我无法build立连接。 这里是代码片段: var tunnel = require('tunnel-ssh') var server = tunnel.tunnel(config.sshData, function(err, result) {console.log('connected'}); 这是我的sshData对象。 config.sshData = {host : 'serverxyz.web-hosting.com', username : 'xyz', password : 'xyz', srcPort: 3307, dstPort : 21098} 21098 文档build议dstPort是21098 。 不过,我收到超时错误,每当我添加此片段: server.on('error', function(err) {}); 我得到的错误server.on is not a function 。 远程连接在putty和SQLyog上工作正常。 任何有关如何build立成功连接的程序都会有很大的帮助。 谢谢! 更新 通过使用指定的正确端口,并通过直接使用ssh2模块与这里给出的代码示例获得数据库的工作

如何使用Node.jsbuild立到MongoDB数据库的SSH隧道连接

我的凭据与Robomongo完美协作,但我无法与node.jsbuild立连接 我试图使用ssh2和tunnel-ssh npm模块进行连接,并且两次都失败。 – mongo连接不需要密码 -sh连接是用pem键进行的 这是我使用ssh2模块的代码,我可以正确build立隧道,但是mongo连接失败 var Client = require('ssh2').Client; var conn = new Client(); conn.on('ready', function() { console.log('Client :: ready'); //mongo connection mongoose.connect('mongodb://localhost:27000/'); var db = mongoose.connection; db.on('error', console.error.bind(console, 'connection error:')); db.once('open', function() { console.log("database connection established"); var users = db.collection('user'); var getallUsers = function (date, callback){ users.find({}).toArray(function(err,data){ callback(data); }) }; getallUsers(null, function […]

脚本来SSH到实例和启动节点app.js

我试图ssh到2个服务器一个接一个,并运行以下命令: sudo node app.js 这是我的代码: #!/bin/bash while read line; do ssh -i "sshtest.pem" ec2-user@$line "sudo node app.js" done < ips.txt 执行sudo节点app.js后,控制权不会转移到循环中的下一个ip。 有人能指出我能做些什么来改善吗?

我可以在Heroku上使用npm private github依赖关系吗?

我试图推送一个Node.js应用程序到Heroku。 该应用程序使用npm来获取在package.json中指定的私人github存储库,像这样… "dependencies": { "my-private-dep": "github:my-org/my-repo" } 由于github主机密钥不在容器known_hosts文件中,构build在npm install阶段失败。 remote: npm ERR! Host key verification failed. 这是SSH的预期行为。 Heroku是否为此提供解决方法? 例如,使用相同buildpack的 dokku有一个主机密钥插件 ,它会在每次构build之前将主机密钥注入到容器中,从而解决此问题。 Heroku有类似的解决scheme吗?

以编程方式在ssh2 nodejs中input密码

我正在使用ssh2 nodejs客户端( https://github.com/mscdex/ssh2 ) 我正在尝试执行以下操作: SSH进入框。 login到docker。 它会重新提示input密码。 input该密码。 我在第三步失败 这是我的代码 var Client = require('ssh2').Client; var conn = new Client(); conn.on('ready', function() { console.log('Client :: ready'); conn.exec('sudo docker ps', {pty: true}, function(err, stream) { if (err) throw err; stream.on('close', function(code, signal) { conn.end(); // data comes here }).on('data', function(data) { console.log('STDOUT: ' + data); }).stderr.on('data', […]

如何使用pm2来部署到Windows堆栈

环境 开发机器:Windows 7 部署目标:Windows 2012 R2 v7.10.1版本v7.10.1 Git git-bash 2.9.2.windows.1 我正在尝试使用PM2部署一个NodeJS项目 PM2部署 我的PM2生态系统文件 deploy : { production : { user : 'myUser', host : '10.1.1.16', ref : 'origin/master', repo : 'pshakr@bitbucket.org/pjma/adapter.git', path : 'C:\\jhu', 'post-deploy' : 'npm install && pm2 startOrRestart ecosystem.config.js –env production' } } 我在开发机器上打开了GIT-Bash ,在运行configuration文件时出现以下错误 错误 $ pm2 deploy ecosystem.config.js production setup […]

我在哪里把我的.js文件?

我使用ssh root从Linode安装了Node.JS,Express,MongoDB等的VPS Ubuntu 10.04服务器。 我想知道的是,如果我有一个名为test-file.js文件与代码: var express = require('express'); var app = express.createServer(); // Configuration app.configure( function() { }); // Routes app.get('/', function(req, res) { res.send('Hello World'); }); app.listen(3000); 如何上传文件或使其与服务器协同工作?

403成功安装Ghost后禁止

我花了几天的时间来搞清楚如何安装病毒Ghost平台,并经历了无数的错误。 幸运的是,我已经设法安装它 – Ghost在我完成npm start –production后给了我一个正面的Ghost is running…消息。 但是,当我浏览到我的网站 – http://nick-s.se – Apache显示其默认页面,当我去到幽灵login区域 – /鬼,该网站返回403 Forbidden。 PS我已经特别安装在不同的端口上运行的Apache的Ghost。 我不知道发生了什么事… 更新 – 我发现我可以通过添加我在config.js中configuration的端口号2368来访问我的Ghost安装。 现在,但是我的问题是 – 如何运行Ghost而不使用这些端口?

Nodejs ssh2只运行多个命令一个terminal

编码我的项目ssh2模块时,我遇到了麻烦。 我试图在一个terminal上运行多个命令来判定远程Linux系统。 例如“bc”命令为您提供了一个基本的计算器,您可以运行它进行基本操作。 但是当你使用的时候,这种进程需要被唤醒(它会接受两个或更多的input,并且会给出响应)。 我需要创build一个像websocket和ssh一样的系统。 当一个websocket收到一个命令时,ssh节点需要执行这个消息,Module需要通过websocket.send()发送它的响应, 我正在使用Node.js websocket,ssh2客户端。 在这里我的代码: #!/usr/bin/node var Connection = require('ssh2'); var conn = new Connection(); var command=""; var http = require('http'); var WebSocketServer = require('websocket').server; var firstcom=true; conn.on('ready', function() { console.log('Connection :: ready'); // conn.shell(onShell); }); var onShell = function(err, stream) { // stream.write(command+'\n'); stream.on('data', function(data) { console.log('STDOUT: ' + data); […]

在节点中使用带有ssh2的pty以sudo执行命令

我需要使用npm ssh2模块为node.js启动sudo over ssh命令; 只读模块的文档我无法弄清楚如何使用pty选项: ssh.on('ready', function() { //not working sudo command: ssh.exec('cd /var/www/website && sudo mkdir myDir', { pty: true }, function(err, stream) { if (err) throw err; stream.on('exit', function(code, signal) { console.log('exit code: ' + code + ' signal: ' + signal); ssh.end(); }); }); }).connect({ host: configuration.sshAddress, port: 22, username: configuration.sshUser, password: […]