Tag: libssh2

节点js:无法在MacOSx / Linux上的ssh2连接中捕获“错误”

this.connection = new Connection(); //ssh2 connection async.waterfall([function(callback) { // some initialization code to connect } }], function(err, opts) { if (err) { callback({ message: 'Error during connecting to the device…', detail: err }, false); } else { console.log('Connecting to … ' + JSON.stringify(self.info)); self.connection.on('ready', function() { console.info('Connected… opening a shell…'); callback(null, true); }).on('error', function(err) { […]

在npm安装期间,libssh2中的“C编译器无法创build可执行文件”

在npm安装nodegit的过程中,我得到以下错误: > nodegit@0.15.1 preinstall /home/mhu/nodegit > node lifecycleScripts/preinstall [nodegit] Running pre-install script [nodegit] npm@2 installed, pre-loading required packages [nodegit] Configuring libssh2. { [Error: Command failed: /bin/sh -c /home/mhu/nodegit/vendor/libssh2/configure –with-libssl-prefix=/home/mhu/nodegit/vendor/openssl/openssl configure: error: in `/home/mhu/nodegit/vendor/libssh2': configure: error: C compiler cannot create executables See `config.log' for more details ] killed: false, code: 77, signal: null, cmd: '/bin/sh -c […]

使用ssh2 sftp节点读取较大的sftp文件

我正在尝试使用ssh2-sftp库在Node中读取/写入文件。 当我在一个sftp站点上对一个更大的CSV文件(但不是太大 – 比如只有2MB)做一个sftp.get,然后在返回的数据stream上读取数据时,第14个stream之后的呼叫挂在我身上。 (“数据”)呼叫。 我已经testing了几个不同的示例文件,代码在较小的文件上工作正常。 但是,如果一个CSV文件足够大,可以通过第14次调用,它就会挂起,就好像它不能再读取一样,即使有更多的读取。 而stream.on(“close”)也永远不会被调用。 显然这是很奇怪的行为。 希望也许有人遇到类似的东西,用这个图书馆,并有一些指导。 如果有帮助,这是一些代码 sftp.get(currentFileName).then((readStream) => { var counter = 0; readStream.on("data", function(d) { counter++; console.log("counter = " + counter); }); readStream.on("close", function(err) { if (err) { console.error("Problem with read stream for file " + currentFileName + ", error = ", err); } //done reading the individual file, […]

在节点中使用带有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: […]