Tag: ssh

节点SSH2连接到路由器

我正在创build一个应用程序,可以在我的工作中通过SSH进入路由器,并根据与WiFi的连接考虑学生。 我有login信息,可以打开一个terminal和SSH使用用户名和密码和运行命令来获取连接设备的列表。 当我用Node.js使用SSH进行设置时,我遇到了一个错误,无法运行任何命令,路由器也踢我的连接。 我假设这是当我尝试运行一个命令,但不能certificate这一点。 下面是我的代码和debugging日志。 任何帮助过滤通过这将不胜感激。 DEBUG: Local ident: 'SSH-2.0-ssh2js0.1.19' DEBUG: Client: Trying 192.168.0.24 on port 22 … DEBUG: Client: Connected DEBUG: Parser: IN_INIT DEBUG: Parser: IN_GREETING DEBUG: Parser: IN_HEADER DEBUG: Remote ident: 'SSH-2.0-dropbear_2013.59' DEBUG: Outgoing: Writing KEXINIT DEBUG: Parser: IN_PACKETBEFORE (expecting 8) DEBUG: Parser: IN_PACKET DEBUG: Parser: pktLen:220,padLen:10,remainLen:216 DEBUG: Parser: IN_PACKETDATA DEBUG: Parser: IN_PACKETDATAAFTER, […]

在Mac OS X上产生的NodeJS进程的pipe道中未处理的stream错误

伙计们! 我正在尝试在NodeJS下构build自己的git服务器。 使用HTTP所有的作品都很好,但是我在ssh2会话中推送过程中遇到了问题。 client.on('session', (accept, reject) => { accept() .on('exec', (accept, reject, info) => { let channel = accept(), command = info.command, regexp = /git-(upload|receive)-pack\'\/(.*?).git\'$/, matches = command.match(regexp); //.. some code //.. command looks like 'git-receive-pack /Users/mykhailobielan/projects/git_server/repos/06565f90-9e22-11e7-94e7-815f98a3fa17.git' command = command.split(' '); var child = spawn(command.shift(), command); child.stdout.pipe(channel); channel.pipe(child.stdin); channel.on('close', (code) => channel.exit(0)); channel.on('error', (code) => […]

在Ubuntu 9上的Node.js + SCP + stdin.write

我对使用Ubuntu 9(无select)有一个怀疑的乐趣,我安装了Node.js。 我想使用SCP(通过ssh复制文件)。 所以我做了一点节点魔法: scpHandler = require('child_process').spawn('scp',['root@192.168.2.16:/user/MyDocs/smsOut.txt', 'smsOut2.txt']); 然后似乎有一个问题 – ssh需要一个密码,我不能通过authorization_keys忽略这个问题,因为他们碰巧不能在这个特定的设备(Maemo)上工作。 所以我想 – 好的,我只是使用stream写作,它会解决一切: scpHandler.stdout.on('data', function(data){ console.log(data); scpHandler.stdin.write('password'); scpHandler.stdin.write('String.fromCharCode(13)'); }); 它应该反映在scp显示任何消息(并要求input密码后)写入密码,但是,正如你现在可以猜到的一样,出现了一些错误,没有什么HAPPENS。 当sc得到正确的密码后,应该有一些数据显示成功/ unsuccesful转移后,但仍然等待密码…请帮助,任何想法是什么错?

github ssh公共密钥没有find与node.js child_process.spawn()在Windows上,但在child_process.exec()可见

此代码适用于Windows和Mac OS X: var exec = require( 'child_process' ).exec exec( 'git clone git@github.com:user/myrepo.git' ) 但是这个代码在Windows上运行时会返回一个来自git的“Access denied(publickey)”错误,但是在Mac OS X上却不会: var spawn = require( 'child_process' ).spawn , child = spawn( 'git', [ 'clone', 'git@github.com:user/myrepo.git' ], { env: process.env } ) child.on.stderr( 'data', function( data ) { console.log( data.toString() ) }) 我假设在spawn我失去了我的连接~/.ssh …但我认为发送process.env将工作。 顺便说一句, git clone命令可以直接在命令提示符下input时在Windows上正常工作。 任何明显的错误?

使用带有shell的Node模块SSH2

我的目标是创build一个Web应用程序,允许用户远程连接到SSH服务器,即不需要在他们的计算机上安装SSH客户端。 所以这意味着我的服务器将是用户和他们的SSH服务器之间的中间接口。 我find了一个用于节点的SSH2模块: https : //github.com/mscdex/ssh2 我想通过使用shell()方法,最合适的连接方法。 以下是获取shell的基本尝试。 var Connection = require('ssh2'); var c = new Connection(); c.on('ready', function() { c.shell(onShell); }); var onShell = function(err, stream) { if (err != null) { console.log('error: ' + err); } stream.on('readable', function() { var chunk; while (null !== (chunk = stream.read())) { console.log('got %d bytes of data', […]

npm太多的本地依赖?

试图摆脱git submodule工作stream程到npm install一个。 我有大约60个独立的库,并将其转换为适当的npm模块。 现在我有package.json具有相当大的dependencies部分,其中每一行是这样的: "libraryN": git+ssh://git@gitlab.company.local:libraryN.git 还有60条这样的线。 每个库都可能有自己的依赖关系,但其中大多数没有依赖关系。 他们彼此独立。 现在,当我做npm install它暂停几秒钟(build立一个单一的依赖列表,我推测),并与以下的SSH错误失败: ssh_exchange_identification: Connection closed by remote host 做了一些实验,我发现package.json的依赖限制数量有所帮助。 所以,有10个或更less的依赖总是没有任何错误的工作。 11至14岁之间偶尔会失败,15岁以上的人总是失败。 看起来这与同步ssh连接到我的本地git存储库服务器有关。 检查了它的日志 – 没有发现可疑的东西。 问题 – 如何一次性安装(和pipe理)所有60个依赖项并避免与ssh相关的问题? 谢谢。

如何使用javascript console.log在ssh中获得相同的空间

我使用node.js运行javascript,并通过Putty查看console.logs。 我怎样才能得到terminal在SSH显示我的东西与标签内联? 我看到两个选项卡空间,但根据第一个string的长度,string跟随是不合适的。 console.log('short'+'\t\t'+'valueA'); console.log('looooooong'+'\t\t'+valueH); 我可能会得到这样的东西 short valueA looooooong valueH 而为了可读性,将会更好看 short valueA looooooong valueH

如何在openshift中引用子模块?

我有一个OpenShift帐户,它提供了每个项目的Git仓库。我有一个主项目和两个较小的项目,总共有3个Git仓库。 我刚刚开始使用主项目中的两个较小的项目,并看到git可以使用submodule命令。 我已经将它们添加到自定义目录中,如下所示: git submodule add ssh://…@app.rhcloud.com/~/git/app.git/ git submodule add ssh://…@api.rhcloud.com/~/git/api.git/ 已经产生了如下目录结构: node_modules custom app —— full of tasty files api —— full of tasty files index.js .gitmodules 我有.gitmodules文件 [submodule "custom/api"] path = custom/api url = ssh://…@api.rhcloud.com/~/git/api.git/ [submodule "custom/app"] path = custom/app url = ssh://…@app.rhcloud.com/~/git/app.git/ 这正是我想要的。 这一切都在本地工作。 git add –all git commit -m "new submodules" […]

NodeJS – 使用“Sequest”检查SFTP远程文件是否存在

我是NodeJS的新手,我使用“Sequest”包来读取SFTP远程文件的内容。 它工作很好。 但是,如果我试图读取的文件不存在,则会抛出exception,应用程序不会进一步响应。 所以我想在读取文件之前检查文件是否存在。 由于我正在使用库函数(sequest.get),因为没有指定文件,我无法处理库方法中发生的exception。 以下是我的代码: var reader = sequest.get('xyz@abc', fileName, opts); reader.setEncoding('utf8'); reader.on('data', function(chunk) { return res.send(chunk); }); reader.on('end', function() { console.log('there will be no more data.'); }); 参考: https : //github.com/mikeal/sequest#gethost-path-opts Sequest( https://github.com/mikeal/sequest )是SSH2的封装( https://github.com/mscdex/ssh2 )。 任何帮助是极大的赞赏。 谢谢。

ssh2中的特殊字符

我正在使用ssh2软件包shell()在nodejs中编写一个linuxterminal。 它适用于我的常规命令,但在编辑vi编辑文件,然后逃脱编辑器,我需要模拟一个“逃生”按键。 我试过这个: stream.write("^[") 在阅读http://man7.org/linux/man-pages/man4/console_codes.4.html但它没有工作。 所以我的问题是 – 如何模拟特殊字符(Ctrl,Shift …)在ssh2中按? 或者是否有任何其他更高的api节点包,我可以用来创build一个terminal?